30

It's a widely sought issue among those who implement In-app billing in Android, that how multiple accounts are dealt with. If a user has multiple accounts configured, which one will be used for in-app billing (as there is no option to let the user select an account)? After digging a lot, following paragraph here seems to explain it..

Note: To make test purchases, the license test account must be on the user’s Android device. If the device has more than one account, the purchase will be made with the account that downloaded the app. If none of the accounts has downloaded the app, the purchase is made with the first account.Users can confirm the account that is making a purchase by expanding the purchase dialog.

I create a developer payload using the account that is involved for in app billing, so that it can be restored properly at a later point in time or on some other device. But since Honeycomb, there is no such thing as Primary Account. A user can delete any account, may be the one with which the app was purchased, in which case, the first account from list of accounts will be used for billing. Now, if i know which account was used and if it occurs to be 'not the account with which app was installed', I can at least inform the user that the following purchases will not be restored later.

So, my question is..

Is there a way to find which account was used for downloading the application?

Google Play does seem to use this information. Anyway we can interact with Google Play upto this level?

note: PackageManager doesn't seem to deal with this.

Maulik
  • 3,286
  • 18
  • 31
Achin Kumar
  • 767
  • 6
  • 11
  • interested in the same thing – Greg Dec 02 '13 at 10:13
  • 1
    can you record the account that was first used to do the first purchase or first open? (it's definitely not the same as play store level accuracy) – Edison Feb 04 '14 at 17:16

2 Answers2

2

If you want to get the name of account mail id which is configured to play store account currently. Please use it . I am putting here only for email name but you can get all information of account like type , descriptin from account object

  Pattern emailPattern = Patterns.EMAIL_ADDRESS; 
            Account[] accounts =        AccountManager.get(this).getAccountsByType("com.google");
            for (Account account : accounts) {
                if (emailPattern.matcher(account.name).matches()) {
                    primaryEmailID = account.name;

                }
            }
Jay Dwivedi
  • 396
  • 1
  • 14
0

My gut feeling tells me to create your own AccountManager and SyncAdapter combo. In order to control the account associated with your in app billing. You could then potentially support merging of accounts on your server (if the user takes action and decides to merge accounts) and handle billing to the same person or based on their accounts. As well as restore purchases to the same device if you want to allow that. You could enforce device policies etc. using Google Play Licensing and eg. DeviceLimiter

If the user deletes the old account your AccountManager and SyncAdapter combo would create a new account and the user would then be forced to merge accounts on your server in order to restore previous purchases and you would have the new "Primary Account" information stored there.

Like Edison said in your comments. There has to be a way to record the account associated with the first purchase and go from there.

These are just my thoughts and I hope we could shed some light on this and figure out a "best practice" to support this.

ejohansson
  • 2,602
  • 1
  • 19
  • 30
  • This does not solve the overall issue. For example, in our app we have implemented AccountManager and SyncAdapter containing accounts associated with users on our server. Each user on our app can purchase a subscription. The problem is that we also want to support multiple users on a device (like Google does on most of their apps). So how can a user have 2 accounts on our app on the same device, with subscription on both of them? Currently this is rather very complex to implement because of the billing system implemented by Google Play regarding user accounts. – Bogdan Zurac Jun 15 '15 at 15:50
  • This is something that you have to handle using a server side support. If your app supports more than one account, you need a way to notify a server that there are two 'connected' account. When the user purchases a product with IAB, you can inform the server that there is a new purchase for a particular google account and you have a way to extend the purchase to the other account too. This is not handled by google, it is a piece of logic you have to handle client and server side. – Mimmo Grottoli Jul 10 '15 at 08:04