Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?
like image 613
UsAaR33 Avatar asked Jun 20 '14 01:06

UsAaR33


People also ask

How do I know if an app is compatible with Google Play?

Below the Install link, you'll see a green message that lets you know this particular app is compatible, incompatible or partially compatible with your device or devices. Click on the “+” to reveal the compatibility details for the app or game.

Is there any official API to get app details from the Play Store?

Try this google official api: github.com/googlesamples/android-play-publisher-api/tree/master/…

How do you check if app is installed or not in Android programmatically?

Call the method isPackageInstalled() : boolean isAppInstalled = isPackageInstalled("com. android. app" , this.

How do I list all Android apps installed on device programmatically?

You can Find the List of installed apps in Android Device by using below code, "packageInfo" Contains Installed Application Information in Device. we can retrive Intent for the application installed from the packageinfo object and by using startactivity(intent), can start application.


1 Answers

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.

like image 132
Manuel Allenspach Avatar answered Oct 14 '22 19:10

Manuel Allenspach