简体   繁体   中英

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. 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.

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. If so, launch a service in background to download the required APK and run this code to silently install it.

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. Please note that a rooted device can be dangerous and cause security breach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM