I got it!! If I use FLAG_ACTIVITY_CLEAR_TOP all activities on the top of the activity to be launched will be destroyed. That should not be happened in my case. Instead of destroying it, t should be brought back behind the activity launched. so I have to use intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT ); in both cases. :-)
On Aug 3, 1:15 pm, Shabu Thomas <[email protected]> wrote: > In my application, activity A is the default one and I have created > another activity B. There is a button in each activity. On click event > of the button, the other activity should be brought to front. So, for > the first click, the activity will be created (OnCreate will be > called) and for the subsequent clicks, new instances should not be > created but it should be brought to front only (OnNewIntent should be > called). > > Button click of Activity B will do the same. But, when we click the > button on A, instead of calling OnNewIntent of B, OnCreate will be > called which means B will again be created. How can we avoid it? > > public void OnMyButtonClickOfA(View view) > { > Intent i = new Intent(this, B.class); > i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | > Intent.FLAG_ACTIVITY_SINGLE_TOP ); // What should I do here in order > to avoid the recreation of B? > > i.putExtra("string", "Again Called"); > startActivity(i); > > } > > public void OnMyButtonClickOfB(View view) > { > Intent intent = new Intent(this, A.class); > intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | > Intent.FLAG_ACTIVITY_SINGLE_TOP ); > //intent.putExtra("MyClass", m); > intent.putExtra("string", "Recalled"); > startActivity(intent); > > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

