In my application I want to create a feature which would on startup check if there is a new version of the application available. If yes then show an alert with "Yes/No" options.
I already tried to use a library from this guy GitHub . I tried to do it via pure GitHUB and via UpdateFrom.XML but nothing seems to work.
I have something like this
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
val toolbar: Toolbar = findViewById(R.id.toolbar)
setSupportActionBar(toolbar)
val policy: StrictMode.ThreadPolicy = StrictMode.ThreadPolicy.Builder().permitAll().build()
StrictMode.setThreadPolicy(policy)
val drawerLayout: DrawerLayout = findViewById(R.id.drawer_layout)
val navView: NavigationView = findViewById(R.id.nav_view)
val toggle = ActionBarDrawerToggle(
this,
drawerLayout,
toolbar,
R.string.navigation_drawer_open,
R.string.navigation_drawer_close
)
drawerLayout.addDrawerListener(toggle)
toggle.syncState()
drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED)
navView.setNavigationItemSelectedListener(this)
var updater = AppUpdater(this)
.setUpdateFrom(UpdateFrom.XML)
.setDisplay(Display.DIALOG)
.setTitleOnUpdateAvailable("Nová verzia dostupná")
.setContentOnUpdateAvailable("Stiahnite si prosím novú verziu aplikácie")
.setTitleOnUpdateNotAvailable("Nová verzia nie je dostupná")
.setContentOnUpdateNotAvailable("Nová verzia aplikácie nie je dostupná. Skúste neskôr")
.setButtonUpdate("Stiahnúť")
.setButtonDismiss("Neskôr")
.setIcon(R.drawable.ic_system_update_white_24dp)
.setCancelable(false)
.setUpdateXML("https://github.com/MyAccount/MyApp/tree/master/app/src/main/res/xml/provider_paths.xml")
updater.start()
}
As I said above. I want to check a version of the app and if there is a newer version than download it and update a current version of the app.
To quickly answer your question - yes , you can store your releases in GitHub releases page, then hard-code the link to that page in your app, and using a clever parser (or GitHub API) you would be able to get links for apps to download. So doing it manually is possible for sure.
But instead, I'll try to convince you not to do this , and there are multiple reasons I can think of. You should always use a distribution channel like Google Play or other alternatives .
So yeah, lots of reasons not to do it yourself. This is just from the top of my head (and not knowing reasons behind your question), but there are probably many more points to add.
And sure, there's probably an extremely narrow use-case when you'd really want to force updates manually, but in any case I'd recommend you to think about the consequences of going along this path.
Update : Google will be releasing (has released?) a library that would allow you to check for updates, but even then you'd need to think about forcing updates in advance - at least one version ahead. Note also that Google services are not up-to-date on every device, and they're not available in many regions, so this is not 100% reliable either.
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.