Android Detect What Caused The Onpause
Solution 1:
in the onPause()
you can call isFinishing()
to know if the activity is finishing for whatever may be the reason or simply getting paused. See the doc here
Solution 2:
But first please check whether your logic that you have written comes to onBackPressed()
. write some log to confirm that that part of your code is active
If i understand you correctly. You have one activity which has some view from that activity you have started another activity. But you want when you click back key of the latest activity some actions you have to perfrom in previous activity. If this is the case you have to write logic in onResume()
method. Because as soon as you click back key activity on top is finished and your focus comes to onResume()
method of previous activity. donot override onKEyDown()
or onBackPressed()
.
Donot forget to vote if you feel my response is useful for you.
Thanks Deepak
Post a Comment for "Android Detect What Caused The Onpause"