Sketchware में Google Account Sign-In Feature जोड़ें – Account Picker से, बिना API Key
🔐 Google Account Sign-In using Account Picker in Sketchware (No API)
Hello developers! 👋
In today’s tutorial, I’ll show you how to create a Google Account Sign-In feature in Sketchware using the built-in Account Picker. No need for Google Sign-In API or any complex setup!
Note: This method only picks Google account emails from your device. It does not authenticate using Google OAuth.
🛠️ Step 1: Create New Project
- Create a new project in Sketchware Pro
- Enable Firebase Authentication in project settings
- In layout, add:
- Linear (vertical)
- Button labeled
Sign in with Google Account
👆 Step 2: Add Account Picker Intent
In onClick event of the button, use this code in asd block:
Intent intent = com.google.android.gms.common.AccountPicker.newChooseAccountIntent(
null, null, new String[]{"com.google"}, false, null, null, null, null);
startActivityForResult(intent, 94);
⚙️ Step 3: Add Components
- FirebaseAuth
- FilePicker (for handling onActivityResult)
🎯 Step 4: Handle Account Picked
In onFilePicked event, use this code (asd block):
};
break;
};
break;
case 94:
try {
_onAccountPicked(
_data.getStringExtra(android.accounts.AccountManager.KEY_ACCOUNT_NAME).toString(),
_data.getStringExtra(android.accounts.AccountManager.KEY_ACCOUNT_TYPE).toString()
);
} catch (Exception e) {
};
if (false) {
📧 Step 5: Create MoreBlock – onAccountPicked
Create a MoreBlock:
onAccountPicked(String email, String type)
Inside it:
- Create string variables:
str_email = email
str_password = email + "123456"
- Use
Sign in with Email & Password
block
🔐 Step 6: Handle Sign-In and Create Account
In on sign-in error, add this logic:
if (error_message.contains("There is no user record corresponding to this identifier")) {
firebaseAuth.createUserWithEmailAndPassword(str_email, str_password);
} else {
SketchwareUtil.showMessage(getApplicationContext(), error_message);
}
✅ Step 7: On User Created Successfully
- In on create user complete block, show a success toast or navigate user
🎉 App Summary
Congratulations! 🥳 Your Sketchware app now supports Google Account Sign-In using the native Android account picker and Firebase. This is perfect for internal tools, basic apps, or login features that don’t need full Google OAuth.
For production-level apps, you should consider using the Google Sign-In API with OAuth for better security.
0 Comments