Keeping the Android app alive
Add it in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.shewenbiao:AppKeepAlive:Tag'
}
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
var notification: Notification? = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
notification = getForegroundNotification()
}
KeepAliveManager.start(
this,
ForegroundNotificationConfig(getForegroundNotificationId(), notification)
)
// or
// KeepAliveManager.start(this, null) //Adopt the system default notification style
}
}