RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
静默安装android,静默安装软件

android在root权限下实现apk的静默卸载,静默安装,重启

1.静默卸载实现:

成都创新互联公司自2013年创立以来,是专业互联网技术服务公司,拥有项目网站制作、成都网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元广饶做网站,已为上家服务,为广饶各地企业和个人服务,联系电话:18982081108

/**

* 静默卸载app

*

* @param context

* @param packageName app的包名

* @throws IOException

* @throws InterruptedException

*/

public static void uninstallApp(Context context, String packageName) throws IOException, InterruptedException {

    ListPackageInfo packageInfos = context.getPackageManager().getInstalledPackages(PackageManager.GET_ACTIVITIES);

    for (PackageInfo packageInfo1 : packageInfos) {

        if (packageName.equals(packageInfo1.packageName)) {

            String suPath = "/system/xbin/su";

            File file = new File(suPath);

            if (!file.exists()) {

                suPath = "/system/bin/su";

            }

            Process process = Runtime.getRuntime().exec(suPath);

            String cmd = "pm uninstall " + packageName + "\n" + "exit\n";

            process.getOutputStream().write(cmd.getBytes());

            process.waitFor();

            break;

        }

    }

}

2.静默安装实现:

/**

* 静默安装app

*

* @param filePath

* @throws IOException

* @throws InterruptedException

*/

public static void installApp(String filePath) throws IOException, InterruptedException {

    String suPath = "/system/xbin/su";

    File file = new File(suPath);

    if (!file.exists()) {

        suPath = "/system/bin/su";

    }

    Process process = Runtime.getRuntime().exec(suPath);

    String cmd = "pm install -r " + filePath + "\n" + "exit\n";

    process.getOutputStream().write(cmd.getBytes());

    process.waitFor();

}

最后加上重启命令:

/**

* 重启系统

*

* @return

*/

public static boolean reboot() {

    try {

        String suPath = "/system/xbin/su";

        File file = new File(suPath);

        if (!file.exists()) {

            suPath = "/system/bin/su";

        }

        Process process = Runtime.getRuntime().exec(suPath);

        String cmd = "reboot\nexit\n";

        process.getOutputStream().write(cmd.getBytes());

        return true;

    } catch (IOException error) {

        return false;

    }

}

注意卸载和安装需要在子线程中执行;如果单纯关机则用“reboot -p”命令。

Android 静默安装和自启动(1、Root环境下)

各种以android硬件平台为基础的【公示屏】、【广告屏】等等,虽然很少有升级,但是不可避免的会遇到,而此类APP的使用场景,一般没人会去帮助你版本更新,点击安装,故而需要:静默安装。

1、确认安装包是否存在,并可读写

2、隐示启动:action和data的schema来控制弹出安装工具类APP,然后点击安装...

3、升级完:BootReceiver 监听到Intent.ACTION_PACKAGE_REPLACED,然后自启动

静默安装apk接口,无需开放root,也无需system权限。

Android静默安装

个人了解到的静默安装的方式有以下4种:

我看了一些第三方的应用市场,一般在设置下都会有前两种静默安装的方式可供选择,而后两种静默安装的方式主要是厂商自己的应用市场使用。

如果在7.0的系统上使用第三种静默安装的方式会出现以下错误:

参考:

Android7.0的静默安装失败问题研究

Android N 静默安装和卸载

主要步骤如下:

我试了以上两篇文章的介绍的方法,还是失败,提示Failure [null],不知道怎么破了,可能是厂商的定制问题吧。。。还在思考中。。。


网站名称:静默安装android,静默安装软件
文章地址:http://scyingshan.cn/article/hocije.html