androidapkupdatingself-updating

Self updating app


TL:DR; version ;)

.

problem:

How do I solve this without any user interaction?

http://code.google.com/p/auto-update-apk-client/ This seems to be a solution, but there must be better approach.

I already found this: Install Application programmatically on Android

but that doesn't solve my problem.


Solution

  • 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:

    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />