Skip to content

r-oung/android-silent-update

Repository files navigation

Silent Update

This sample shows how to update Android app silently without user confirmation using a device owner app.

Usage

  1. Build app and install on device
adb install -r <apk-filename>
  1. Set app as device owner
 adb shell dpm set-device-owner com.hrst.silent_update/.DeviceAdmin
  1. Increment versionCode (in app's build.gradle) of the app and rebuild again.

  2. Push the new APK with updated versionCode to the device

adb push app-update.apk /sdcard/Download/.
  1. Start the app (old version) and select UPDATE APP. This should install the new version of the app from the specified location. The app should then automatically restart and show the new version.

Notes

Enable Device Owner via ADB

Remove all accounts from device Settings > Accounts. Enable developer mode and then USB debugging. Then enable device owner via ADB:

adb shell dpm set-device-owner com.hrst.update_app/.DeviceAdmin

You should get the following message:

Success: Device owner set to package ComponentInfo{com.hrst.update_app/com.hrst.update_app.DeviceAdmin}
Active admin set to component {com.hrst.update_app/com.hrst.update_app.DeviceAdmin}

Reference:

Removing Device Owner

In temi (Android 6), if the app has device admin privileges, disabling this privilege must come from within the app. Otherwise it will become impossible to uninstall the app without a hard factory reset.

Since Android 7, the dpm command can be used to remove device owner:

adb shell dpm remove-active-admin com.hrst.update_app/.DeviceAdmin

You should get the following message:

adb shell dpm remove-active-admin com.hrst.update_app/.DeviceAdmin

Alternatively, go to Settings > Security > Device Administrators and disable the app.

References:

About

Android silent update example

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages