activity
activity

Reputation: 2733

Showing Admob video interstitial causes crash when Back button pressed quickly

I'm showing an interstitial at the end of a game level. When the user presses the Back button very quickly, a crash sometimes occurs:

java.lang.IllegalStateException
at android.media.MediaPlayer.getDuration(Native Method)
at com.google.android.gms.ads.internal.overlay.l.a(SourceFile:180)
at com.google.android.gms.ads.internal.overlay.n.run(SourceFile:204)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
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:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)

I'm using the latest version of Google Play Services (v25). The code for showing Admob interstitial is already inside a try-catch block, but this doesn't help.

Is there a way to prevent that crash?

Upvotes: 0

Views: 384

Answers (2)

William
William

Reputation: 20196

There is no way to catch the exception. It is thrown from the UI thread with none of your code in the stack.

It will undoubtedly be fixed by Admob in the near future.

Upvotes: 0

Aman Satija
Aman Satija

Reputation: 1975

Are you sure your try catch block has caught IllegalStateException ?

try{


}catch(IllegalStateException e){

}

if not you must catch illegalStateException

Upvotes: 1

Related Questions