现在的位置: 首页 > 综合 > 正文

android 调用安装界面

2014年01月14日 ⁄ 综合 ⁄ 共 440字 ⁄ 字号 评论关闭

Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

intent.setAction(android.content.Intent.ACTION_VIEW);

/* 调用getMIMEType()来取得MimeType */

String type = "application/vnd.android.package-archive";

/* 设置intent的file与MimeType */
intent.setDataAndType(Uri.parse("file://" + apkPath), type);
/*
* 经过实验,发现无论是否成功安装,该Intent都返回result为0 具体结果如下: type requestCode
* resultCode data 取消安装 10086 0 null 覆盖安装 10086 0 null 全新安装 10086 0
* null
*/
context.startActivity(intent);

抱歉!评论已关闭.