简体   繁体   中英

How to make an app updater for android app?

I'm making an android app that won't go on google play and I want to be able to update it. The way I would do this is by having a server hold a JSON with the newest APK version and link to the APK and on App Launch I want to check the App's version against the APK held by the JSON. If the version on the JSON is the most recent I want to prompt the user for an update. My app is a webview, not sure if that makes a difference

I'm quite new to App Development and Java so I'm not sure how to make this however. The HTTP Request for the JSON is the part I've mostly understood and I've found some good posts about the App Update code on App launch but I can't make sense of it.

I'd appreciate any tips, thank you

Step 1:

If you do not have app in google play store then you need to make API, which helps to get version of your app stored in your server database:

Step 2:

Then You need to call api from your app and match the version from the server database and from your app.

I am attaching code to get version from your app:

val versionCodeFromServer = /*Get It From Your API From The Server Database*/
try {
   if (packageManager != null) {
       val pInfo = packageManager.getPackageInfo(packageName, 0)
       val version = pInfo.versionName
       if (!versionCodeFromServer.equals(version, ignoreCase = true)) {
          showAppUpdateDialog() //Show User that you need to update app.
       }
   }
} catch (e: PackageManager.NameNotFoundException) {
   e.printStackTrace()
}

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