The registration for C2DM may result in an error ACCOUNT_MISSING. This error must be handled, according to the documentation, in this way "The application should ask the user to open the account manager and add a Google account."
I would like to offer to the user this possibility from the application. I have seen two ways to show this screen:
//Intent
context.startActivity(newIntent(Settings.ACTION_ADD_ACCOUNT).putExtra(Settings.EXTRA_AUTHORITIES, new String[] {?}));
The problem for this solution that the I have tried several EXTRA_AUTHORITIES ("com.google", "com.google.android.gsf, etc) and none of them show anything and if the parameter EXTRA_AUTHORITIES is omitted all the phone account are shown.
//Account manager
AccountManager.get(context).addAccount("com.google", null, null, null, this, new AccountManagerCallback<Bundle>() {
public void run(AccountManagerFuture<Bundle> accountManagerHandle) {
//TODO Handle response.
}
}, null);
}
The problem for this solution is that it requires the permission MANAGE_ACCOUNTS, and the users would probably not like to accept an extra permission just for that.
How would you deal with this situation?