/**
* 通过包名 在应用商店打开应用
*
* @param packageName 包名
*/
private void openApplicationMarket(String packageName) {
try {
String str = "market://details?id=" + packageName;
Intent localIntent = new Intent(Intent.ACTION_VIEW);
localIntent.setData(Uri.parse(str));
startActivity(localIntent);
} catch (Exception e) {
// 打开应用商店失败 可能是没有手机没有安装应用市场
e.printStackTrace();
Toast.makeText(LearnActivity.this.getContext().getApplicationContext(), "打开应用商店失败", Toast.LENGTH_SHORT).show();
// 调用系统浏览器进入(小米)商城
String url = "http://app.mi.com/details?id="+packageName+"&ref=search";
openLinkBySystem(url);
}
}
/**
* 调用系统浏览器打开网页
*
* @param url 地址
*/
private void openLinkBySystem(String url) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
startActivity(intent);
}
Android通过包名打开手机应用商城寻找所指定App
最新推荐文章于 2024-06-05 11:22:26 发布