У меня есть проблема с моим сервисом (JobIntEntentService), где метод OnCreate () прекрасно работает при перезагрузке (под управлением Android-R-11), но как только я заставляю убить APK (используя команду убийства -9) или просто выполняю «Установку ADB» после того, как я изменяю его, процесс APK подходит, но Oncreate () никогда не вызывается. Я вижу эти сообщения, хотя после того, как процесс снова становится активным: < /p>
06-06 12:07:55.466 23558 23579 I m.test.svc: Waiting for a blocking GC ProfileSaver
06-06 12:07:55.478 23558 23579 I m.test.svc: WaitForGcToComplete blocked ProfileSaver on AddRemoveAppImageSpace for 12.485ms
06-06 12:07:55.494 23558 23572 I m.test.svc: WaitForGcToComplete blocked RunEmptyCheckpoint on ProfileSaver for 14.509ms
06-17 11:27:12.040 9550 9571 I m.test.svc: WaitForGcToComplete blocked ProfileSaver on ClassLinker for 11.334ms
06-17 11:27:12.054 9550 9564 I m.test.svc: WaitForGcToComplete blocked RunEmptyCheckpoint on ProfileSaver for 13.742ms
< /code>
Я бы признателен за любыми указателями. Вот соответствующие фрагменты кода: < /p>
private fun createNotificationChannel(): String {
val channelId = "my_service"
val channelName = "My Background Service"
val chan = NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_HIGH)
chan.lightColor = Color.BLUE
chan.importance = NotificationManager.IMPORTANCE_NONE
chan.lockscreenVisibility = Notification.VISIBILITY_PRIVATE
val notificationMgr = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
notificationMgr.createNotificationChannel(chan)
return channelId
}
private fun initiateForeground() {
val channelId = createNotificationChannel()
val notificationBuilder = NotificationCompat.Builder(this, channelId)
val notification = notificationBuilder.setOngoing(true)
.setSmallIcon(R.drawable.ic_launcher)
.setPriority(NotificationManager.IMPORTANCE_HIGH)
.setCategory(Notification.CATEGORY_SERVICE)
.build()
startForeground(101, notification)
}
override fun onCreate() {
super.onCreate()
initiateForeground()
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... ce-restart