单击 Google 播放 link 检查我的应用程序是否已下载

Check if my app is downloaded by clicking on Google Play link

我正在开发 android 应用程序。

在这个应用程序中我只有一个按钮。如果用户单击此按钮,它将被重定向到 Google 在特定应用程序上播放 link。

有什么方法可以知道用户是否下载了该应用程序?

要重定向到 google 游戏商店:

Intent viewIntent = new Intent("android.intent.action.VIEW",
Uri.parse("https://play.google.com/store/apps/details?id=app_packge_name"));
startActivity(viewIntent);

Intent viewIntent = new Intent("android.intent.action.VIEW",
Uri.parse("market://details?id=app_packge_name"));
startActivity(viewIntent);

检查应用程序是否安装:

private boolean isPackageInstalled(String packagename, Context context) {
    PackageManager pm = context.getPackageManager();
    try {
        pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
        return true;
    } catch (NameNotFoundException e) {
        return false;
    }
}

检查应用程序是否从 google Play 商店安装:

public static boolean isAppFromPlayStore(Context context, String packageName) {
     boolean result = false;
     String installer = context.getPackageManager()
                        .getInstallerPackageName(packageName);
     if(installer!=null && installer.equals("com.android.vending")){
          result = true;
     }
     return result;
}