onHandleWork не запускается. Служба работает нормально ниже android 10.
class IncidentImageUploadService : JobIntentService() {
private var eventModel: String? = null
private var incidentId: Int? = null
private var sS3Client: AmazonS3Client? = null
private var sMobileClient: AWSCredentialsProvider? = null
private var sTransferUtility: TransferUtility? = null
override fun onHandleWork(intent: Intent) {
eventModel = intent.getStringExtra(BeontConstant.UPLOAD_ADD_INCIDENT_IMAGE)
incidentId = intent.getIntExtra(BeontConstant.INCIDENT_ID, -1)
if (eventModel != null) {
if (!eventModel!!.isNullOrEmpty()) {
println("message"+eventModel)
}
}
}
override fun onStopCurrentWork(): Boolean {
return true
}
companion object {
val JOB_ID = 23
fun enqueueWork(context: Context, work: Intent) {
enqueueWork(context, IncidentImageUploadService::class.java, JOB_ID, work)
}
}
}
Вот так я запускаю JobIntentService:
val intentUpload = Intent(activity!!, IncidentImageUploadService::class.java)
intentUpload.putExtra(BeontConstant.UPLOAD_ADD_INCIDENT_IMAGE, fileName)
intentUpload.putExtra(BeontConstant.INCIDENT_ID, model.id)
IncidentImageUploadService.enqueueWork(activity!!, intentUpload)
Так я определил службу в манифесте под приложением :
<service
android:name=".services.IncidentImageUploadService"
android:permission="android.permission.BIND_JOB_SERVICE" />
Любая помощь будет высоко ценится. Спасибо