How to find Gmail account associated with Android Market?

前端 未结 3 779
無奈伤痛
無奈伤痛 2020-12-11 17:00

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);
          


        
3条回答
  •  轮回少年
    2020-12-11 17:50

    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.

提交回复
热议问题