Reputation: 714
I have an android application created in android studio.
I want to check daily whether an update is available for my app or not. if yes, then notify user to download and install the update.
I searched a lot and I found many answers such as using these:
I faced some problems for example:
connectivity change
is deprecated in android 7I want to know which one best suits my job. and how to do it.
thanks in advance.
Upvotes: 0
Views: 528
Reputation: 73826
You should use WorkManager you can set it to run once a day and even only run when there is an internet connection.
In the work manager you would make a the call to check your app version then show a notification if there is an update.
Create the work manager somewhat like this
val constraints = Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build()
val dailyBuilder = PeriodicWorkRequestBuilder<DailyMaintenanceWorker>(1, TimeUnit.DAYS).setConstraints(constraints) .build()
WorkManager.getInstance(this).enqueueUniquePeriodicWork("DailyMaintenanceWorker", ExistingPeriodicWorkPolicy.KEEP, dailyBuilder)
Upvotes: 1