ตอนนี้คุณก็พร้อมสร้างตัวอย่างและเรียกใช้จาก Android Studio แล้ว
สร้างตัวอย่างแล้วคลิกปุ่มเรียกใช้ แล้วเลือกอุปกรณ์หรือโปรแกรมจำลองที่เชื่อมต่อซึ่งมีบริการ Google Play เวอร์ชันล่าสุด
วิธีการทำงาน
แอปพลิเคชันจะสร้าง GoogleSignInClient โดยระบุตัวเลือกการลงชื่อเข้าใช้ที่ต้องการ จากนั้นเมื่อคลิกปุ่มลงชื่อเข้าใช้ แอปพลิเคชันจะเริ่มความตั้งใจในการลงชื่อเข้าใช้ ซึ่งจะแจ้งให้ผู้ใช้ลงชื่อเข้าใช้ด้วยบัญชี Google
// Configure sign-in to request the user's ID, email address, and basic// profile. ID and basic profile are included in DEFAULT_SIGN_IN.GoogleSignInOptionsgso=newGoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
// Build a GoogleSignInClient with the options specified by gso.mGoogleSignInClient=GoogleSignIn.getClient(this,gso);
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-09-20 UTC"],[[["\u003cp\u003eGoogle Sign-In for Android is outdated and developers should migrate to Credential Manager for enhanced security and user experience.\u003c/p\u003e\n"],["\u003cp\u003eCredential Manager supports passkey, password, and federated identity authentication, including Sign-in with Google.\u003c/p\u003e\n"],["\u003cp\u003eWear OS developers should continue using Google Sign-In for Android until Credential Manager support is available for their specific Wear OS versions.\u003c/p\u003e\n"],["\u003cp\u003eTo use the provided sample app, configure a Google API Console project with an Android and a Web application client ID.\u003c/p\u003e\n"],["\u003cp\u003eThe sample app demonstrates how to build a \u003ccode\u003eGoogleSignInClient\u003c/code\u003e and initiate the sign-in process with a user's Google account.\u003c/p\u003e\n"]]],[],null,[]]