i created an App the problem with it is when i exit the app using finish() in OnDestroy() the app still running in the background how to exit that when i exit the App from the menu
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Android is quite complex regarding management of app lifecycle. Actually it manages activity lifecycles. You may want to read this – it is REALLY helpful in understanding the most important aspects of it. http://developer.android.com/reference/android/app/Activity.html
But be aware any of your activity classes may exist in memory even AFTER the system has called onDestroy on your activity. Therefore your app might not start the same way as it has done initially. At least the static variables of the activity might still have the same value as when the activity was finished and even destroyed!
All you should do is maximally call finish() and take care of your activity variables, especialy the static ones!
Even calling finish() might not really be necessary, since going back on the last activity does the same.
ps as a small hint, put log into these system methods like finish, onDestroy,… and all the others to better understand what is going on. I am sure you will be suprised 🙂