[英]How to update android app automatically without Google Play or user interaction
I'm developping an application that will run on a tablet device in a store (eg restaurant).我正在开发一个应用程序,该应用程序将在商店(例如餐厅)的平板电脑设备上运行。 The device does not have Google Play and is rooted.
该设备没有 Google Play 并且已植根。 How do I install an update to my application automatically, with absolutelly NO user interaction?
如何在完全没有用户交互的情况下自动为我的应用程序安装更新?
To clarify, checking for a new version of APK hosted on my server and downloading it are not part of this question, only the "silent" update part is.澄清一下,检查托管在我的服务器上的新版 APK 并下载它不是这个问题的一部分,只有“静默”更新部分是。
First of all, your device needs to be rooted.首先,您的设备需要植根。 It seems this is already done for you.
看来这已经为您完成了。 Now all you have to do is to make your application check if a new version of the APK is available.
现在您要做的就是让您的应用程序检查是否有新版本的 APK 可用。 If so, launch a service in background to download the required APK and run this code to silently install it.
如果是这样,请在后台启动服务以下载所需的 APK 并运行此代码以静默安装它。
public static void InstallAPK(String filename){
File file = new File(filename);
if(file.exists()){
try {
String command;
command = "adb install -r " + filename;
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
proc.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}
You can basically modify the ABD command to perform whatever you want.您基本上可以修改 ABD 命令以执行您想要的任何操作。 Please note that a rooted device can be dangerous and cause security breach.
请注意,root 设备可能很危险并导致安全漏洞。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.