I am very confused in using finish() for activity and using back button of keypad.I have created many activities so on moving from one activity to another I finish the last activity. And also I have used back button in my activity so I can go back (from where I came)
by pressing back button but problem arises when I use keypad’s back button I go to any other activity .I want it should work as my activity’s back button.
And I think this can be done by using onKeyListener and chekcing keypad’s back buttons and there I start activity same as my activity’s back button.
I want to know is it right to do this way or there is a way better than this?
Please Help
There is a better way:
You should not call
finish()when going from one activity to another. If the memory is needed, the OS will clear it for you, and when you press back it will work as needed. Just make sure your lifecycle functions are correct (you clean up big chunks of memory hogging stuff when you loose focus etc), and you’ll be a much happier coder .