简体   繁体   中英

Android override application after reboot

i'm developing an system application for android. I found a problem during the application update. I installed V1.0 but when install the new version(V1.1) it replace the old one without errors,but if the phone is rebooted or powered off the application came back to 1.0 Do you have any suggestion to fix this issue?

Increase versionCode when you update the app

In fact, the latest version of your app is installed into /data/app , when device reboot, the device will check whether the old app(v1.0) should be updated or not. However, according to scanPackageLI() in frameworks/base/services/java/com/android/server/PackageManagerService.java

if (ps != null && !ps.codePath.equals(scanFile)) {
    // The path has changed from what was last scanned...  check the
    // version of the new path against what we have stored to determine
    // what to do.
    if (pkg.mVersionCode < ps.versionCode) {
        // The system package has been updated and the code path does not match
        // Ignore entry. Skip it.
        ......
    } else {
        ......
    }
    ......
}

You can find if versionCode is the same, old app will not update. So you need to increase versionCode in your app when you want to update old app.

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