How to find Gmail account associated with Android Market?
From what I have found, the first google account added in the device is the primary google address which is associated with android market. Also, we get google accounts in the order it was added in the device. So, accounts[0] will be the first email-Id added.
String marketAssociatedEmailId = "";
Account[] accounts = AccountManager.get(context).getAccountsByType("com.google");
if(accounts.length > 0) {
marketAssociatedEmailId = accounts[0].name;
}
Again, I am not sure about this. You have to test it yourself with various scenarios.
The dialog
is caused by the implementation of AbstractAccountAuthenticator#getAccountRemovalAllowed in the Google account authenticator.
Since calling implementations of AbstractAccountAuthenticator
directly is prevented by the system-only permission android.permission.ACCOUNT_MANAGER
you're going to have a hard time finding this out on your own.