资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

静默安装android,静默安装参数

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

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

创新互联公司基于成都重庆香港及美国等地区分布式IDC机房数据中心构建的电信大带宽,联通大带宽,移动大带宽,多线BGP大带宽租用,是为众多客户提供专业绵阳主机托管报价,主机托管价格性价比高,为金融证券行业服务器托管,ai人工智能服务器托管提供bgp线路100M独享,G口带宽及机柜租用的专业成都idc公司。

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

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

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

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

android如何实现静默安装哦

原理

静默安装、卸载的原理就是利用pm install命令来安装apk,pm uninstall 来卸载apk.

智能安装是利用android系统提供的无障碍服务AccessibilityService,来模拟用户点击,从而自动安装.

//静默安装

private void installSlient() {

String cmd = "pm install -r /mnt/sdcard/test.apk";

Process process = null;

DataOutputStream os = null;

BufferedReader successResult = null;

BufferedReader errorResult = null;

StringBuilder successMsg = null;

StringBuilder errorMsg = null;

try {

//静默安装需要root权限

process = Runtime.getRuntime().exec("su");

os = new DataOutputStream(process.getOutputStream());

os.write(cmd.getBytes());

os.writeBytes("\n");

os.writeBytes("exit\n");

os.flush();

//执行命令

process.waitFor();

//获取返回结果

successMsg = new StringBuilder();

errorMsg = new StringBuilder();

successResult = new BufferedReader(new InputStreamReader(process.getInputStream()));

errorResult = new BufferedReader(new InputStreamReader(process.getErrorStream()));

String s;

while ((s = successResult.readLine()) != null) {

successMsg.append(s);

}

while ((s = errorResult.readLine()) != null) {

errorMsg.append(s);

}

} catch (Exception e) {

e.printStackTrace();

} finally {

try {

if (os != null) {

os.close();

}

if (process != null) {

process.destroy();

}

if (successResult != null) {

successResult.close();

}

if (errorResult != null) {

errorResult.close();

}

} catch (Exception e) {

e.printStackTrace();

}

}

//显示结果

tvTest.setText("成功消息:" + successMsg.toString() + "\n" + "错误消息: " + errorMsg.toString());

}

Android静默安装与静默卸载(系统应用)

一.轰隆一声雳响,我闪亮登场。

本篇基于已有系统证书(从Android设备厂家获得)的情况下实现静默安装与静默卸载,可分为三部分讲解:将apk内置为系统应用,apk静默安装与apk静默卸载。

1.将apk内置为系统应用。内置的方法有共性,也有区别。基础操作是共性,区别就在于Android4.4以上版本与Android4.4以下版本。

2.apk静默安装。

3.apk静默卸载。

二.若您觉得本文对您有帮助,记得点个关注哟~

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

1.静默卸载实现:

/**

* 静默卸载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静默安装

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

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

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

参考:

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

Android N 静默安装和卸载

主要步骤如下:

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


当前题目:静默安装android,静默安装参数
当前地址:http://cdkjz.cn/article/dsshjio.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220