I have two activities Activity A and B, Activity A has 3 fragments namely 
a1,a2 and a3. a3 is the default selected fragment which shows videos, a2 
contains one big textView and a small edittext in it and a1 contains a 
listview. 

Now On activity A's title bar I have a button, and since it is on title bar 
it is visible from all 3 fragments. OnClick of this button I open Activity 
B. using Following function. 

public void inviteUser() {
if ( getUserType() == ACTIVE ) {
Intent intent = new Intent(this, B.class);
intent.putExtra(Constants.MEETING_ID, (long) session.getSessionId());
intent.putExtra(Constants.INVITE_FROM_SESSION, true);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | 
Intent.FLAG_ACTIVITY_SINGLE_TOP);
this.startActivityForResult(intent, RESULT_OK);
} else {
Toast.makeText(this, getString(R.string.strNotAPresenterMsg), 
Toast.LENGTH_LONG).show();
}
}

Inside B I call its `setResult(ResultCode) and finish()`. Now I have **two 
problems** when I ***start B from Fragments a1 and a2,***

1. B takes too much time before returning back to A (i.e. after pressing 
back button or after finishing the work of B), 2. It doesn't show any 
dialog after returning until either I navigate to some other fragment or I 
rotate the device, once I do that it starts behaving normally and 
surprisingly, when I start the activity ***B from fragment a3,*** it 
returns immediately and behaves normally. 

I have tried overriding all the life cycle methods of these fragments and 
put the Log statements inside each method. Pain is that method calling 
sequence is normal and same for both the cases. However I notice that 
onDestory and onStop of activity B (Child Activity) are never called, when 
I start B from a1, a2 and press the back button once B is started. 

The doc says that "The visible lifetime of an activity happens between a 
call to onStart() until a corresponding call to onStop(). During this time 
the user can see the activity on-screen, though it may not be in the 
foreground and interacting with the user."

Since onStop() is not guaranteed the activity behaves abnormally when it is 
not called.. I also came to know that in HoneyComb+ devices it is always 
called. I have tried calling onStop() inside onPause() but that is not 
working. What I do now ?

*More Information :-*

1. I have tried changing the flags of the intent but to no gain. 

2. I have added falg `android:configChanges="keyboardHidden|orientation"` 
for all the activities of my app. 

3. Hope I explained the problem, in case any one need any specific part of 
the code. please comment.I will edit the question and add that. Help guys!!!

4. I was testing in GingerBread 2.3.6 it was not working but I just checked 
that on emulator running JellyBean and it is working fine. Looks like the 
issue is related to OS version. Any idea ?

5. One important point of observation is that When in B I press back 
button, after few mili seconds the onResume() of Previous Activity and 
their fragments are called. But even after that B is on Screen for some 
time and that seems like phone hanged for few seconds.... 

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to