Here you can find the source of isInstalledThroughPlayStore(final Context context)
Parameter | Description |
---|---|
context | Context |
public static boolean isInstalledThroughPlayStore(final Context context)
//package com.java2s; //License from project: Apache License import android.content.Context; import android.content.pm.PackageManager; public class Main { /**//from w ww . j a v a 2s. c om * Check whether the application is installed through the Play Store. * * @param context Context * @return true when the app is installed through the Play store, otherwise false */ public static boolean isInstalledThroughPlayStore(final Context context) { final PackageManager packageManager = context.getPackageManager(); final String packageInstallerName = packageManager .getInstallerPackageName(getPackageName(context)); if ("com.android.vending".equals(packageInstallerName)) { // App is installed through the Play Store return true; } return false; } /** * Get the application package name. * * @param context Context * @return package name */ public static String getPackageName(final Context context) { return context.getPackageName(); } }