Android进入商店并跳转到指定应用
效果图
对话框
// 提示好评Dialog dialog = new AlertDialog.Builder(this).setTitle("评价").setMessage("大爷,给个好评吧~~").setPositiveButton("准奏", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {openApplicationMarket("com.bitmain.btccom");}}).setNegativeButton("滚粗", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {Toast.makeText(getApplicationContext(), "关闭", Toast.LENGTH_SHORT).show();}}).setNeutralButton("别再烦我", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialog, int which) {// TODO 设置下次不再提醒Toast.makeText(getApplicationContext(), "不再提醒", Toast.LENGTH_SHORT).show();}}).create();dialog.show();
进入商店
/*** 通过包名 在应用商店打开应用** @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(getApplicationContext(), "打开应用商店失败", Toast.LENGTH_SHORT).show();// 调用系统浏览器进入商城String url = "/detail/163525?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);}
其他
打开应用商店
try {Intent intent = new Intent(Intent.ACTION_MAIN);intent.addCategory(Intent.CATEGORY_APP_MARKET);intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);startActivity(intent);} catch (Exception e) {e.printStackTrace();}
如果觉得《Android进入商店并跳转到指定应用》对你有帮助,请点赞、收藏,并留下你的观点哦!