Self updating app

后端 未结 3 1198
青春惊慌失措
青春惊慌失措 2021-01-30 03:12

TL:DR; version ;)

  • my app should run without user interaction (autostart etc works)

  • it should update itself (via apk) without any user interactio

3条回答
  •  深忆病人
    2021-01-30 03:55

    Solved it! :D

    It just works in rooted devices but works perfectly. Using the unix cmd "pm" (packageManager) allows you to install apks from sdcard, when executing it as root.

    Hope this could help some people in the future.

    public static void installNewApk()
    {
            try
            {
                Runtime.getRuntime().exec(new String[] {"su", "-c", "pm install -r /mnt/internal/Download/fp.apk"});
            }
            catch (IOException e)
            {
                System.out.println(e.toString());
                System.out.println("no root");
            }
    }
    

    Required permissions:

    
    
    

提交回复
热议问题