android 在代码中安装apk的方法

第一步:保存apk文件到sdcard或者其他地方

第二步:修改apk文件的权限为可执行 ,例如chmod ‘777’ file:

String command = "chmod " + permission + " " + path;
Runtime runtime = Runtime.getRuntime();
runtime.exec(command);

第三步:使用Intent 调用安装:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setDataAndType(Uri.parse("file://" + path),"application/vnd.android.package-archive");
context.startActivity(intent);

更多相关文章

  1. Android中简单调用图片、视频、音频、录音和拍照的方法
  2. android自定义title的方法
  3. 国内阉割版安卓手机无法使用google maps
  4. Failed to push the item
  5. 我的第一个Android程序——HelloWorld
  6. Android中关于sdcard的操作
  7. Android(安卓)Studio初体验
  8. android 设置控件的字体
  9. Android(安卓)SurfaceTexture解读

随机推荐

  1. MTK Android 编译命令
  2. Android 倒影实现算法
  3. Android(安卓)Service 启动流程
  4. android 浮窗
  5. R文件没有生成或报错
  6. Android SDK无法更新终极解决方式
  7. Android 读取XML的两种方法。
  8. Ubuntu 12.04 Desktop 版本编译 Android
  9. Android SQLite数据库解析并使用两种方法
  10. 【Android-Third】Android三方框架相关