android7.0 静默安装,可以用来更新已经安装的应用。无法获取安装进度,可以使用系统广播来监听应用的安装、卸载、更新。7.1.2版本亲测可行。不过使用了系统签名再次签名!

/**
 * 静默安装
 * @param installPath
 * @param packageName
 * @return
 */
public static boolean installApkInSilence(String installPath, String packageName,int flag) {LogUtil.e("installApkInSilence "+AppCenter.isSystemApp);
   if(!AppCenter.isSystemApp){return false;
   }LogUtil.e("installApkInSilence ");
   Class<?> pmService;
   Class<?> activityTherad;
   Method method;
   try {activityTherad = Class.forName("android.app.ActivityThread");
      Class<?> paramTypes[] = getParamTypes(activityTherad, "getPackageManager");
      method = activityTherad.getMethod("getPackageManager", paramTypes);
      Object PackageManagerService = method.invoke(activityTherad);
      pmService = PackageManagerService.getClass();
      Class<?> paramTypes1[] = getParamTypes(pmService, "installPackageAsUser");
      method = pmService.getMethod("installPackageAsUser", paramTypes1);
      method.invoke(PackageManagerService, installPath, null, 0x00000002, packageName, getUserId(Binder.getCallingUid()));//getUserId
      LogUtil.e("installApkInSilence ok");
      return true;
   } catch (ClassNotFoundException e) {LogUtil.e("installApkInSilence ClassNotFoundException"+e.getMessage());
      Write.debug("installApkInSilence ClassNotFoundException"+e.getMessage());
   } catch (NoSuchMethodException e) {LogUtil.e("installApkInSilence NoSuchMethodException"+e.getMessage());
      Write.debug("installApkInSilence NoSuchMethodException"+e.getMessage());
   } catch (IllegalAccessException e) {LogUtil.e("installApkInSilence IllegalAccessException"+e.getMessage());
      Write.debug("installApkInSilence IllegalAccessException"+e.getMessage());
   } catch (InvocationTargetException e) {LogUtil.e("installApkInSilence InvocationTargetException"+e.getMessage());
      Write.debug("installApkInSilence InvocationTargetException"+e.getMessage());
   }return false;
}private static Class<?>[] getParamTypes(Class<?> cls, String mName) {Class<?> cs[] = null;
   Method[] mtd = cls.getMethods();
   for (int i = 0; i < mtd.length; i++) {if (!mtd[i].getName().equals(mName)) {continue;
      }cs = mtd[i].getParameterTypes();
   }return cs;
}

android7.0 静默安装相关推荐

  1. 华为android7.0 root,android7.0更新安装apk的方法

    StrictMode模式 从android7.0开始强制启用StrictMode"严苛模式".StrictMode是在android2.3引进的类.当时它的作用是作为一个开发工具用 ...

  2. Android7.0以上 安装Ca证书

    必须要root 不root的手机执行不了下面的命令行 root的话 请百度怎么root并自行承担风险 第一步  将花瓶或者fidder的证书下载下来保存.这里推荐用cer.pem的我没有测试也许会不行 ...

  3. Android7.0以上安装时出现“解析软件包错误”

    工作中,vivoX9s,版本号:7.1.2,在Android studio上调试软件出现"解析软件包错误",不管是项目工程还是自己新建的hellowrold工程都会出现这个问题,如 ...

  4. Android 7.0下载安装APK

    Android 7.0下载安装APK 这里只说安装,不说下载.因为下载网上一搜一大堆,暂且说下一下Android7.0 下载安装APK时的兼容性问题. 简介 随着Android版本越来越高,Andro ...

  5. 鹅厂bugly应用升级不能安装(Android7.0的新变化)

    app升级是每一个android应用的标配了,大部分应用都会有升级提醒和apk下载安装(如果系统允许静默安装估计就没有提醒这段了). 以前的升级是自己写http下载或者通过系统提供的DownloadM ...

  6. Oracle 12c(12.1.0.5) oem agent silent install(静默安装agent)

    注释: 文章来自oracle support 文档 ID 1360083.1,静默安装agent采用的是把OMS服务端(即oem server端)的agent用压缩包download,远程传到agen ...

  7. Oracle Database 11.2.0.1(静默安装)

    http://www.cnblogs.com/ylqmf/archive/2012/04/16/2451211.html 本文档是Oracle Database 11.2.0.1 for RHEL5 ...

  8. 静默安装oracle11.2.0.4

    静默安装Oracle11gR2 环境: oracle11.2.0.4 redhat6.2 1.  登录到root用户下,检查以下包是否存在,如果不存在,则需要安装:(root用户) 检查:rpm -q ...

  9. Android开发之下载Apk安装的方法兼容Android7.0和8.0及以上

    具体查看代码: 首先在清单文件配置三个权限读写权限和请求安装权限(兼容Android8.0手机)如下: <!--安装apk权限--><uses-permission android: ...

最新文章

  1. Hrefer教程【超越官方】
  2. 一个命名管道可以被多个客户端访问吗_Redis 的事务机制和管道技术Pipelining
  3. 第二章作业-第3题-万世想
  4. robot1,Mechanical structure
  5. Java_Freemarker
  6. alink的相關資料收集
  7. php拖拽原理,JS拖拽效果及原理解析
  8. Java数据结构与算法(12) - ch06递归(回文anagram)
  9. centos如何安装数据库mysql
  10. 为什么你说的话别人不愿意听?
  11. 在leangoo里怎么添加泳道?
  12. 现实世界的Windows Azure:采访Definition 6首席技术官Paul Hernacki
  13. 时间管理表 - 《待办清单列表》
  14. 什么是SG?+SG模板
  15. @guardedby同步注解
  16. 认识计算机键盘ppt教案,认识计算机键盘.ppt
  17. JNA释放Memory对象分配的内存
  18. 使用 Hexo 快速免费搭建个人网站
  19. 办公技巧巧用Excel群发电子邮件(转)
  20. 【软件工程】软件工程知识点提纲8

热门文章

  1. mvc html.PartialView()传参
  2. 若不曾忘记,便不必追忆
  3. Echarts在一个容器中绘制多张横向条形统计图
  4. C# Winfrm窗体 chart控件应用(条形统计图,折线统计图,扇形统计图)
  5. 技术类图书聚合的小众网站推荐
  6. 证券类APP如何运营?拉新篇
  7. rosdep update总是显示time out解决办法。
  8. SAP将“在中国,为中国”贯彻到底!
  9. 微信小程序设置页面背景颜色backgroundColor 无效的问题!
  10. 网页浏览远程网络视频