📜  重启服务 ondestroy android - 任何代码示例

📅  最后修改于: 2022-03-11 14:55:24.082000             🧑  作者: Mango

代码示例1
AppLog.i("System UI Service is Restarting")
        val startSystemUiIntent = Intent(context, AwesomeService::class.java)
        val restartServicePendingIntent = PendingIntent.getService(context, 1, startSystemUiIntent, PendingIntent.FLAG_ONE_SHOT)

        val alarmManager = getSystemService(ALARM_SERVICE) as AlarmManager
        alarmManager.setExact(AlarmManager.RTC_WAKEUP, SystemClock.currentThreadTimeMillis(), restartServicePendingIntent)


        stopService(Intent(context, SystemUIService::class.java))