首页 > 移动平台 > 详细

android怎样调出apk安装界面

时间:2016-05-31 12:16:51      阅读:287      评论:0      收藏:0      [点我收藏+]

开发一个android应用程序,必须有的一个功能就是更新应用的版本。

那么点击更新版本的控件后,应该如何调出apk的安装界面呢?

技术分享

/**
     * 安装程序
     * 
     * @param context    上下文
     * @param file    apk的保存路径
     */
    public static void openFile(Context context, File file) {
        try {
            Intent mIntent = new Intent();
            mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            mIntent.setAction(android.content.Intent.ACTION_VIEW);
            mIntent.setDataAndType(Uri.fromFile(file),
                    "application/vnd.android.package-archive");

            context.startActivity(mIntent);

        } catch (Exception e) {
            e.printStackTrace();

            ToastUtils.showToast(
                    context,
                    context.getResources().getString(
                            R.string.toast_openApk_error), false);
        }

    }

 

android怎样调出apk安装界面

原文:http://www.cnblogs.com/wangchaozhangshu/p/5545261.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!