mopub/mopub-client — Issue #28: Crash on android.intent.action.SCREEN_OFF 
Author: compbatant
Created: 2012-01-12 01:34:59+00:00
State: open

java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.SCREEN_OFF flg=0x40000000 } in com.mopub.mobileads.MoPubView$1@405ddb60
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:722)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.mopub.mobileads.MoPubView$1.onReceive(MoPubView.java:179)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:709)
... 9 more
java.lang.NullPointerException
at com.mopub.mobileads.MoPubView$1.onReceive(MoPubView.java:179)
at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:709)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:3806)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)

===========
SOLUTION

change:

mPreviousAutorefreshSetting = mAdView.getAutorefreshEnabled();
if (mAdView != null) mAdView.setAutorefreshEnabled(false);

to:

if (mAdView != null) {
mPreviousAutorefreshSetting = mAdView.getAutorefreshEnabled();
mAdView.setAutorefreshEnabled(false);
}