Android 下载安装APK
2012-08-13 00:36 javaspring 阅读(362) 评论(0) 编辑 收藏 举报代码安装apk
- Intent i = new Intent(Intent.ACTION_VIEW);
- String filePath = "/sdcard/XXX.apk";
- i.setDataAndType(Uri.parse("file://" + filePath),"application/vnd.android.package-archive");
- context.startActivity(i);
程序卸载
- Intent intent = new Intent(Intent.ACTION_DELETE, uri);
- intent.startActivity();
监听是否卸载成功
- DeleteReceiver mDeleteReceiver = new DeleteReceiver();//自定义的广播接收类,接收到结果后的操作
- IntentFilter filter = new IntentFilter(
- Intent.ACTION_PACKAGE_DATA_CLEARED);
- filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
- filter.addDataScheme("package");
- registerReceiver(mDeleteReceiver, filter); //注册广播和过滤
- Intent undeleteIntent = new Intent(Intent.ACTION_DELETE, packageURI);
- startActivity(undeleteIntent);