Errr... we need a damn edit button here. i meant: " since having it as 
"started" does *<not>*  guarantee that the fragment is visible."  :)


On Monday, April 15, 2013 11:47:22 AM UTC+3, Piren wrote:
>
> After onStart has been called and before onStop. 
> You can be more pedantic about the state if needed - using 
> isHidden/isVisible/isResumed .. since having it as "started" 
> does  guarantee that the fragment is visible.
>
> On Monday, April 15, 2013 11:32:45 AM UTC+3, William Ferguson wrote:
>>
>> Hi Piren, what is an appropriate definition of "Started" in this instance?
>>
>> WIlliam
>>
>> On Monday, April 15, 2013 1:17:36 AM UTC+10, Piren wrote:
>>>
>>> Check the fragment state before showing, it should be Started, if not, 
>>> keep a flag saying that says this dialog needs to be shown. Check for the 
>>> flag state during onStart/onResume and show the dialog if needed
>>>
>>> On Sunday, April 14, 2013 4:25:03 PM UTC+3, William Ferguson wrote:
>>>>
>>>> I have a Fragment that fires an async task to connect to a remote 
>>>> server. If it fails to connect (eg times out) then I use use a Handler to 
>>>> display a dialog to the user.
>>>>
>>>> final DialogFragment newFragment = 
>>>>> AlertDialogFragment.createConnectionFailedDialog(getSupportActivity());
>>>>> newFragment.show(getFragmentManager());
>>>>
>>>>
>>>> All good except that the async task if the user navigates away from the 
>>>> Activity hosting that Fragment (eg goes to Preferences) then when the time 
>>>> out occurs the Fragment is in a quasi shut down state and the following 
>>>> exception is thrown.
>>>>
>>>> 04-14 23:11:51.407: ERROR/AndroidRuntime(6267): FATAL EXCEPTION: main
>>>>>         java.lang.IllegalStateException: Can not perform this action 
>>>>> after onSaveInstanceState
>>>>>         at 
>>>>> android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1327)
>>>>>         at 
>>>>> android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1338)
>>>>>         at 
>>>>> android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:595)
>>>>>         at 
>>>>> android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:574)
>>>>>         at 
>>>>> org.holoeverywhere.app.DialogFragment.show(DialogFragment.java:369)
>>>>>         at 
>>>>> org.holoeverywhere.app.DialogFragment.show(DialogFragment.java:350)
>>>>>         at 
>>>>> org.holoeverywhere.app.DialogFragment.show(DialogFragment.java:329)
>>>>>         at 
>>>>> au.com.xandar.wirelesstiming.connection.ConnectionFragment.updateUserInterfaceOnClose(ConnectionFragment.java:197)
>>>>>         at 
>>>>> au.com.xandar.wirelesstiming.connection.ConnectionFragment.access$200(ConnectionFragment.java:26)
>>>>>         at 
>>>>> au.com.xandar.wirelesstiming.connection.ConnectionFragment$2.run(ConnectionFragment.java:96)
>>>>>         at android.os.Handler.handleCallback(Handler.java:725)
>>>>>         at android.os.Handler.dispatchMessage(Handler.java:92)
>>>>>         at android.os.Looper.loop(Looper.java:137)
>>>>>         at android.app.ActivityThread.main(ActivityThread.java:5041)
>>>>>         at java.lang.reflect.Method.invokeNative(Native Method)
>>>>>         at java.lang.reflect.Method.invoke(Method.java:511)
>>>>>         at 
>>>>> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
>>>>>         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
>>>>>         at dalvik.system.NativeStart.main(Native Method)
>>>>
>>>>
>>>> What is the correct way to handle this scenario?
>>>>
>>>> Ideally I'd like to always display the dialog, but if that is not an 
>>>> option, then what do I use to determine whether the dialog should be 
>>>> displayed or not?
>>>>
>>>>
>>>> William 
>>>>
>>>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to