Double back press to exit the application best method (android) in fragment

 private var backPressedTime : Long = 0



if (backPressedTime + 2000 > System.currentTimeMillis()) {
requireActivity().finishAffinity()
} else {
showToast(MyApplication.context!!, "Press Back again to exit ", IndiaHaatConstants.ToastType.CUSTOM)
}
backPressedTime = System.currentTimeMillis()

Comments

Popular posts from this blog

Delay using coroutine, splash activity delay, kotlin global scope

Handler and looper in splash