Programmatically Starting The 'add Account' Activity In Android 2.2
I've been experimenting with the Android SDK over the past few days, in readiness to write an App for the store, however I've run across a bit of a problem. The App I'll be writing
Solution 1:
Check out the ACTION_ADD_ACCOUNT
startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT));
Solution 2:
Try the following:
publicstaticvoidaddGoogleAccount(final Activity activity) {
finalAccountManageraccountMgr= AccountManager.get(activity);
accountMgr.addAccount("com.google", "my_auth_token", null, null, activity, null, null);
}
Solution 3:
the answer for the above question by providing EXTRA_ACCOUNT_TYPES in the intent extra data. and set the value to "com.google" in order to alert the activity:
publicstaticvoidstartAddGoogleAccountIntent(Context context){
Intent addAccountIntent = newIntent(android.provider.Settings.ACTION_ADD_ACCOUNT)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
addAccountIntent.putExtra(Settings.EXTRA_ACCOUNT_TYPES, newString[] {"com.google"});
context.startActivity(addAccountIntent); }
Solution 4:
Android Account Manager provides an API to add account. (google or other account types)
public AccountManagerFuture addAccount (String accountType, String authTokenType, String[] requiredFeatures, Bundle addAccountOptions, Activity activity, AccountManagerCallback callback, Handler handler)
http://developer.android.com/reference/android/accounts/AccountManager.html
Solution 5:
The clue is in your shell command:
Intentintent=newIntent();
intent.setClassName( "com.google.android.gsf", "com.google.android.gsf.login.AccountIntroActivity" );
context.startActivity( intent );
Post a Comment for "Programmatically Starting The 'add Account' Activity In Android 2.2"