Created
September 29, 2020 19:46
-
-
Save robertohuertasm/96e3c49470d7793ba08ce962e975aa93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onTaskRemoved(rootIntent: Intent) { | |
val restartServiceIntent = Intent(applicationContext, EndlessService::class.java).also { | |
it.setPackage(packageName) | |
}; | |
val restartServicePendingIntent: PendingIntent = PendingIntent.getService(this, 1, restartServiceIntent, PendingIntent.FLAG_ONE_SHOT); | |
applicationContext.getSystemService(Context.ALARM_SERVICE); | |
val alarmService: AlarmManager = applicationContext.getSystemService(Context.ALARM_SERVICE) as AlarmManager; | |
alarmService.set(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime() + 1000, restartServicePendingIntent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment