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();}

更多相关文章

  1. Android开机自启APK应用
  2. Android让所有应用都竖屏显示或者横屏显示
  3. Android平板电脑不能全屏显示的问题
  4. Android应用开发相关下载资源(2014/10/19更新)
  5. Android(安卓)在一个应用中如何启动另外一个已安装的应用
  6. 2010.12.27——— android service
  7. android应用程序组件之间的通讯
  8. android 学习五 设置应用程序全屏(没有状态栏和标题栏)
  9. 2010.12.27——— android service

随机推荐

  1. 【Android】Webview常见问题
  2. Android(安卓)OpenCV 颜色识别
  3. Android学习笔记——Android(安卓)PullTo
  4. google的GCM推送使用简介
  5. Android(安卓)package属性、package name
  6. Android(安卓)OpenGL ES 分析与实践(2)
  7. 2010-09-21 15:58 [摘]Android如何将程序
  8. Animation & Property Animation 使用
  9. Android线程中Handle的使用
  10. Flutter环境的搭建