Android进入商店并跳转到指定应用
16lz
2021-12-04
Android进入商店并跳转到指定应用
效果图
对话框
// 提示好评Dialog dialog = new AlertDialog.Builder(this) .setTitle("评价") .setMessage("大爷,给个好评吧~~") .setPositiveButton("准奏", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { openApplicationMarket("com.bitmain.btccom"); } }) .setNegativeButton("滚粗", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getApplicationContext(), "关闭", Toast.LENGTH_SHORT).show(); } }) .setNeutralButton("别再烦我", new DialogInterface.OnClickListener() { @Override public 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 = "http://app.mi.com/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开机自启APK应用
- Android让所有应用都竖屏显示或者横屏显示
- Android平板电脑不能全屏显示的问题
- Android应用开发相关下载资源(2014/10/19更新)
- Android(安卓)在一个应用中如何启动另外一个已安装的应用
- 2010.12.27——— android service
- android应用程序组件之间的通讯
- android 学习五 设置应用程序全屏(没有状态栏和标题栏)
- 2010.12.27——— android service