简体   繁体   中英

My app is not on the Google Play store,can I get it to auto update?

I have recently finished developing an Android application that does not qualify to be on Google Play store because it does not target a certain SDK. the app will be downloaded directly from my website, but I also want it to support automatically checking for and downloading updates. is there a proper way to achieving this?

You are free to implement an own update mechanic which checks the current app version and compares it with the latest version on your server.

Alternatively, you can check out one of the existing app distribution solutions like Microsoft Appcenter. This allows you to use the Appcenter SDK which can check at each start of the app, if the user uses the latest version.

https://docs.microsoft.com/en-us/appcenter/sdk/distribute/android

I think you have to implement the update criteria from scratch. Well on app open you can check with your server if there is an update, you do this by comparing the version on the server with your versionCode if the version on your server is greater than the version code in your app then you have an update. You can ask then the user to download the apk file, if the user accepts you download the file and use the below snippet to install it.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
        Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE, uriOfDownloadedApk);
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        startActivity(intent);
    }else{
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uriOfDownloadedApk, "application/vnd.android.package-archive");
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(intent);
    }

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