2

My play service which i used in my project is:

compile 'com.google.android.gms:play-services-gcm:9.4.0'
compile 'com.google.android.gms:play-services-analytics:9.4.0'
compile 'com.google.android.gms:play-services-auth:9.4.0'

i have never called to GoogleApiAvailability by my own but i guess when i use gcm or google sign in and it seems that my app crashing becuase that availability checking.

Fatal Exception: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
       at android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1493)
       at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1511)
       at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:638)
       at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:617)
       at android.support.v4.app.DialogFragment.show(DialogFragment.java:139)
       at com.google.android.gms.common.SupportErrorDialogFragment.show(Unknown Source)
       at com.google.android.gms.common.GoogleApiAvailability.zza(Unknown Source)
       at com.google.android.gms.common.GoogleApiAvailability.zza(Unknown Source)
       at com.google.android.gms.internal.zzpn$zza.run(Unknown Source)
       at android.os.Handler.handleCallback(Handler.java:815)
       at android.os.Handler.dispatchMessage(Handler.java:104)
       at android.os.Looper.loop(Looper.java:194)
       at android.app.ActivityThread.main(ActivityThread.java:5631)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:959)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:754)

its look that when there are some issues with the play-services and it should show any dialog to the user but my application already not in foreground so the onSaveInstanceState already happen and some callback which show error dialog rasie IllegalStateException.

Lior
  • 832
  • 6
  • 6

1 Answers1

0

The IllegalStateException error means that your method has been invoked at an illegal or inappropriate time/state for your requested operation.

Here is the complete explanation on why you get this kind of error.

You can try to follow the solution in this issue by overriding the onResumeFragments() instead of OnPostResume.

  • Override OnPostResume, if you extend Activity (for API 11+)

  • Override onResumeFragments, if you extend FragmentActivity.

For more information, check these related threads.

Community
  • 1
  • 1
KENdi
  • 7,576
  • 2
  • 16
  • 31