是否可以在基于ROM的设备上创建静默安装程序?

问题描述:

我一直在想,是否有可能创建一个沉默的安装程序在植根设备上的股票ROM? 我见过一个应用程序:Linux终端模拟器这个应用程序在android上运行shell命令。 当我运行:是否可以在基于ROM的设备上创建静默安装程序?

  1. 苏 -
  2. 下午这个模拟器它默默地安装APK安装myapk.apk

。我想知道这个应用程序如何能够安装一个apk默默地。我的设备已经植根,并有一个股票ROM。

我想知道如果这个应用程序可以做到这一点,我们不能写我们自己的android应用程序来安装apks默默地wothout系统签名文件的ROM?

编辑:默默地我的意思是安装一个应用程序,无需用户提示。

你可以(以非常黑客的方式)使用adb静默安装应用程序。您必须启用USB调试,但只需将APK推送到/ data/app。即:

ADB推MyApp.apk /数据/应用

ADB安装MyApp.apk(更清洁的方式)

第二个命令可提示为安装。但你可以尝试两种。希望它对你有帮助。

+0

谢谢,但我有我跑t来自设备。 – 2014-08-30 04:57:28

您可以使用开源库以root身份运行该命令。看看下面的库:

https://github.com/Stericson/RootTools

https://github.com/SpazeDog/rootfw

https://github.com/Chainfire/libsuperuser

https://github.com/dschuermann/superuser-commands

还是自己做:

Process su = null; 
try { 
    su = Runtime.getRuntime().exec("su"); 
    String cmd = "pm install /path/to/the/apk\n"; 
    su.getOutputStream().write(cmd.getBytes()); 
    String exit = "exit\n"; 
    su.getOutputStream().write(exit.getBytes()); 
    su.waitFor(); 
} catch (Exception e) { 
    e.printStackTrace(); 
} finally { 
    if (su != null) { 
     su.destroy(); 
    } 
}