CopyPastor

Detecting plagiarism made easy.

Score: 0.8632096339381018; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2018-03-20
by Jaimin Sarvan

Original Post

Original - Posted on 2010-10-27
by Abhinav



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Android activities are stored in the activity stack. Going back to a previous activity could mean two things.
You opened the new activity from another activity with startActivityForResult. In that case you can just call the finishActivity() function from your code and it'll take you back to the previous activity.
Keep track of the activity stack. Whenever you start a new activity with an intent you can specify an intent flag like FLAG_ACTIVITY_REORDER_TO_FRONT or FLAG_ACTIVITY_PREVIOUS_IS_TOP. You can use this to shuffle between the activities in your application. Haven't used them much though. Have a look at the flags here: http://developer.android.com/reference/android/content/Intent.html
As mentioned in the comments, if the activity is opened with startActivity() then one can close it with finish(). If you wish to use the Up button you can catch that in onOptionsSelected(MenuItem item) method with checking the item ID against android.R.id.home unlike R.id.home as mentioned in the comments.
Android activities are stored in the activity stack. Going back to a previous activity could mean two things.
1. You opened the new activity from another activity with **startActivityForResult**. In that case you can just call the **finishActivity()** function from your code and it'll take you back to the previous activity.
2. Keep track of the activity stack. Whenever you start a new activity with an intent you can specify an intent flag like `FLAG_ACTIVITY_REORDER_TO_FRONT` or `FLAG_ACTIVITY_PREVIOUS_IS_TOP`. You can use this to shuffle between the activities in your application. Haven't used them much though. Have a look at the flags here: http://developer.android.com/reference/android/content/Intent.html
As mentioned in the comments, if the activity is opened with `startActivity()` then one can close it with `finish()`. If you wish to use the Up button you can catch that in `onOptionsSelected(MenuItem item)` method with checking the item ID against `android.R.id.home` unlike `R.id.home` as mentioned in the comments.

        
Present in both answers; Present only in the new answer; Present only in the old answer;