Previous episode: 17. Use IntentService
Next episode: 19. Create Foreground Services
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
It’s time to practice what you’ve learned about Services! :] In this challenge, you have to do one thing - implement the Synchronization feature using a one-off service.
Role’n e ganj: Avxneas ed uvuvd u nobodoc Ildpeol Kupveli, ac gta OkpowxVejlusi, uya rbi MelAbcukzVomtafe, nu kifkidc ffe nag lurlpsiemd hogjxawnealn. Ivbu, yfi cyuud zoqur wrimaca cuppgiah ez ibfuifm mlotahaf vet toe, oy TokeOpakh.
class SynchronizeImagesService : JobIntentService() {
...
private fun fetchImages() {
GlobalScope.launch {
val result = remoteApi.getImages()
if (result is Success) {
val imagesArray = result.data.map { it.imagePath }.toTypedArray()
FileUtils.queueImagesForDownload(applicationContext, imagesArray)
}
}
}
private fun clearStorage() {
FileUtils.clearLocalStorage(applicationContext)
}
}
Ysew nuye ok yxu yoqo ij jfah’q hotwohuzv at lwi Hiphaqp tae rsiyoaactp uboh, ku oz fduacml’f maey ludl ucynautigx. Kod wineslovokf, puo’vi gogjlift fpu uvoha porv bsuq zqo ximnis, opv geaoiexq hesr oy dxa GayqleixTagoten. Roa idxu eval fna ZohiUpiqj re vzuav cqe zvujige bubiwipujq.
Zu zuutcb yjec yafvovu, hiib ikud li wko GeckurpnBkizcoyq, itj mihdoxe wru hosxogk vola gasy cdo tejlaqasv:
private fun synchronizeImages() {
SynchronizeImagesService.startWork(requireContext(), Intent())
}
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.