Is there any way to control the previous activity when the user presses the back button on the device.
Controlling it by setting a TextView to clear when the user does or ending the previous activity.
Thanks
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.
Of course! Android provides some build in methods that are invoked when events (like pressing the back button and going to a previous activity) take place. These methods are detailed in the Android Activity life cycle.
One way to solve your problem would be by using the onResume method. Inside this method you can set your TextView to whatever you want once the activity is resumed.
One side note, is this code will get fired as the user starts the Activity for the first time. You may need to prevent this happening via a boolean value or use an alternative method to solve your problem like the method
onActivityResultif you feel it is appropriate.