手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android实现用代码简单安装和卸载APK的方法
Android实现用代码简单安装和卸载APK的方法
摘要:本文实例讲述了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程序设计有所帮助。

【Android实现用代码简单安装和卸载APK的方法】相关文章:

android中知道图片name时获取图片的简单方法

android将Bitmap对象保存到SD卡中的方法

Android判断包名和类名是否存在的方法

Android应用程序的调试

Android中隐藏标题栏和状态栏的方法

Android基站定位原理及实现代码

Android中没有插入SD情况下的文件写入和读取方法

android实现字体闪烁动画的方法

android书架效果实现原理与代码

android实现横屏的代码及思路

精品推荐
分类导航