Itโs a little difficult for me to fix this, because I get it through a crash report from another Android device, I have no way to ask them questions, and I have never seen this happen on my own Android devices.
Crash reports say Android 4.1.2 and stack trace:
java.lang.NullPointerException at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:2102) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5021) 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:789) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) at dalvik.system.NativeStart.main(Native Method)
Unfortunately, the Android source code on grepcode.com does not seem to match these line numbers, so I'm not sure which thing is zero.
I donโt know what the user did when this happens, so I donโt know if this happens when playing music or sound effects, or if it happens when being destroyed or something like that. I seem to suspect that this could happen during the destruction. I have the following code in the onDestroy method:
public void onDestroy() { synchronized(curPlayers) { for(List<MediaP> ms : curPlayers.values()) { synchronized(ms) { for(MediaP m : ms) { synchronized(m) { mmstop(); mmrelease(); } } } } curPlayers.clear(); } } private static class MediaP { private MediaP(MediaPlayer m) { this.m = m; } private MediaPlayer m; private boolean wasPlaying = false; }
Is there something out there that I have to do?
source share