Here's the updated code to identify whether the don't keep activities flag is turned on or not.
val dka = Settings.System.getInt(contentResolver,Global.ALWAYS_FINISH_ACTIVITIES) Log.i(TAG,"dka -> $dka")
source