在我的Flash Player中,查看用户是否在Android电子市场中拥有特定应用的最简单方法是什么?如果他们没有它,我希望能够在继续使用该应用程序之前将它们带到市场下载。感谢。
答案 0 :(得分:5)
这是关于检查Flash Player的similar question。
相关代码(取自Lior的答案)是:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.adobe.flashplayer", "com.adobe.flashplayer.FlashExpandableFileChooser"));
PackageManager pm = getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
if (activities != null && activities.size() > 0)
{
Toast.makeText(this, "Flash is installed!", Toast.LENGTH_LONG).show();
}
else
{
Intent flashIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("https://market.android.com/details?id=com.adobe.flashplayer"));
startActivity(flashIntent);
}
答案 1 :(得分:0)
我知道这已经得到了回答,但这是我实现类似的方法:
Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage("com.package.address");
if (intent != null) {
// start the activity
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
// bring user to the market
// or let them choose an app?
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id="+"com.package.address"));
startActivity(intent);
}