I am developing an application that requires a Google account for certain parameters. The options are disabled when the account is not found, but I suggest the user to add it, requesting through a pop-up window, if the user clicks "yes", the action should begin. It works great to display the global "Add Account" page, but I want to skip this unclaimed for an extra step. In the end, why does anyone have the option to add an Exchange account if they need a Google account that is just confusing. Therefore, I want to use the new Google Account Settings page by default.
Java
try { Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setClassName( "com.google.android.gsf", "com.google.android.gsf.login.AccountIntroActivity"); //if(getApplicationContext().getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY) != null) { getApplicationContext().startActivity(intent); //} else { //getApplicationContext().startActivity(new Intent(Settings.ACTION_ADD_ACCOUNT).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); //} } catch ( ActivityNotFoundException e) { e.printStackTrace(); }
When I ran this, the following exeception is thrown:
05-29 18: 24: 50.741: W / System.err (10875): android.content.ActivityNotFoundException: Cannot find explicit activity class {com.google.android.gsf / com.google.android.gsf. login.AccountIntroActivity}; Have you announced this activity in your AndroidManifest.xml?
AndroidManifest.xml
<activity android:name="com.google.android.gsf.login.AccountIntroActivity"/>
QUESTION: what am I missing here?
EDIT:
I tried using addAccount in a different way, it doesnโt work, nothing happens, no errors occur, no new activity starts adding a Google account. By the way, the entire catch try block in the original version is in AlertDialog / listener.
AccountManager acm = AccountManager.get(); acm.addAccount("com.google", null, null, null, null, null, null);