I know how to find accounts (which will include gmail email ids of user) and how to filter gmail account.
AccountManager am = AccountManager.get(context);
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.