for some cases, you can create splash screen page to determine if app has been killed previously by system.
it basically a screen with intent filter main/launcher, and will be finished, and changed to main activity.
so, every time user visit splashScreen, it shows that the app has been killed before, and you can do anything you want to handle.
sample code:
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="id.gits.yourpackage">
<application
android:name=".App">
<activity android:name=".SplashActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
SplashActivity:
class SplashActivity : AppCompatActivity() {
override fun onCreate() {
super.onCreate()
doSomethingAfterAppKilled()
}
}