Android实现用代码简单安装和卸载APK的方法
Android实现用代码简单安装和卸载APK的方法
发布时间:2016-12-28 来源:查字典编辑
摘要:本文实例讲述了Android实现用代码简单安装和卸载APK的方法。分享给大家供大家参考,具体如下:publicclassTestInstal...

本文实例讲述了Android实现用代码简单安装和卸载APK的方法。分享给大家供大家参考,具体如下:

public class TestInstallAPK extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); // this.unInstallFile(); installFile(); } /** * install APK code */ private void installFile(){ Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.Intent.ACTION_VIEW); // String type = getMIMEType(f); // intent.setDataAndType(Uri.fromFile(f), type); intent.setDataAndType(Uri.parse("file://" + "/sdcard/Android_gc.apk"), "application/vnd.android.package-archive"); this.startActivity(intent); } /** * uninstall APK code */ private void unInstallFile(){ Uri uri=Uri.parse("package:com.gameclient"); Intent intent = new Intent(Intent.ACTION_DELETE,uri); this.startActivity(intent); } }

希望本文所述对大家Android程序设计有所帮助。

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新安卓软件开发学习
热门安卓软件开发学习
编程开发子分类