UsAaR33
UsAaR33

Reputation: 3686

How do I programmatically determine if an app in the play store can be installed on current device?

In my app, I'm recommending related apps, but only want to recommend them if they actually can be installed on the device (e.g. device in related apps' targeted countries, correct OS version, etc.). See https://developer.android.com/google/play/filters.html

  1. Is there any API that allows me to query if a given app I am recommending by linking to market://details?id=package_name can be installed on the local device?
  2. If not, I could manually store the other apps' requirements in my own app. But then, how do I determine items such as the country the users' Play Store is associated with?

Upvotes: 19

Views: 4600

Answers (2)

Manuel Allenspach
Manuel Allenspach

Reputation: 12735

Unfortunately, there is no API to compare an app with specific devices. The Play Store is it doing somehow internally.

So, the second approach is the way to go. The most common filters are

  • Country (since you can't retrieve the "play store country", use other approaches...)

    String locale = context.getResources().getConfiguration().locale.getCountry(); 
    // or if you are sure there is a SIM-card
    TelephonyManager tm = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String countryCode = tm.getSimCountryIso();
    // or use country of current network (i.e. from 3G)
    String countryCode = tm.getNetworkCountryIso()
    
  • Android version

    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.GINGERBREAD) {
        // only for gingerbread and newer versions
    }
    
  • Screen size

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;
    

You may want to check other things like the available sensors (which you could do via getSensorList). To list them all would create a very long list and finding all APIs to find these things is mostly easy, so I won't list them all.

By checking country, version and screen size you should be safe with most of the apps.

Upvotes: 12

Stephan Branczyk
Stephan Branczyk

Reputation: 9375

Is there any API that allows me to query if a given app I am recommending by linking to market://details?id=package_name can be installed on the local device?

Yes, sort of, but the api/trick I'm thinking about may not fit your requirements at all.

It's an experimental Google feature, as far as I know it's for web applications only (not Android apps, although I suppose it might work with an Android web browser and your resulting application may not end up looking native), it requires your users to have a Google+ login (not just a gmail account), and you need to be manually whitelisted by Google in order to use it.

The idea is that once you login with Google+ on your (whitelisted) third party web site, you can click on the install button located on the third party web site and the third party web site will popup a window giving you a one-click install button to confirm the permissions and do a remote install for an over-the-air update.

As you can see from the url bar of the screenshot below, the popup window actually comes from the Google Play domain, so technically, it's just a simple trick that's meant to give the user the ability to install an application without leaving completely your web site.

Also, I want you to notice the current pull-down select box with the name of your device in it. You can't see it here, but the selection box contains all of the registered devices with your Google+ account, and it only shows black font for your device(s) that are compatible with the actual application in question.

screenshot of beta tunin radio web site with Google plus and Google Play integration

Now for the bad news. In this example, the web site belongs to TuneIn radio and the Android application belongs itself to TuneIn radio as well. I personally have no idea if this feature could be enabled for a web site listing Android applications that it doesn't own itself. That would be a question you'd have to ask Google.

Currently, this api is still just web only. This is an objection that the Google employees may raise when you ask them to whitelist your application.

Currently, TuneIn radio allows you to register devices with your Google+ account, but it doesn't show anything of what I saw in the presentation I attended. In the presentation I saw, there was no registration of devices required by the user, everything was done seamlessly once Google+ sign-in was associated with the account. So looking at the tunein.com radio web site itself may not be very useful to you.

And finally, I believe Google frowns upon other third party App stores, so before pleading your case to Google to try to get yourself included for the whitelist of this api. Make sure to carefully comply with the terms and services of the Google Play Store and be prepared to think about how Google would eventually benefit from allowing you (and others like you) to use this kind of feature.

Here is the slide deck on github (for some reason, the display of the slide deck itself no longer works for me). You need to contact either of those Google employees to get you whitelisted for this api. Their contact info/Google+ info is in the slide deck.

Please let us know of you progress. I'd be very interested to know if you can overcome any of the problems I've listed above.

Upvotes: 2

Related Questions