Cannot determine whether Google play store is installed or not on Android device

后端 未结 5 1226
自闭症患者
自闭症患者 2020-12-08 21:27

This was a simple matter of checking the installed packages on the device... before I\'ve upgraded my OS to 2.3.5, I could locate the Market/Play store, using this code:

5条回答
  •  生来不讨喜
    2020-12-08 22:00

    In most case we want to find out whether Google Play Store is installed or not to launch it with some app page preloaded.

    Why cant we do this:

    final String appPackageName = getPackageName(); // get your app package name
    try {
        Uri uri = Uri.parse("market://details?id=" + appPackageName);
        startActivity(new Intent(Intent.ACTION_VIEW, uri));
    } catch (android.content.ActivityNotFoundException anfe) {
        // Google Play Store is not available.
    }
    

提交回复
热议问题