问题描述
我出版了我的应用程序,并在某些手机上像Galaxy Nexus的还是HTC资源管理器在我的应用程序崩溃。
我测试了许多手机和应用程序完美工作。
你能解释我为什么会出现这种情况,如何解决?
错误
java.lang.IllegalStateException
在android.media.MediaPlayer.isPlaying(本机方法)
在com.mario.kvizoman.SoloIgra.novopitanjce(SoloIgra.java:922)
在com.mario.kvizoman.SoloIgra.onClick(SoloIgra.java:901)
在android.view.View.performClick(View.java:2485)
在android.view.View $ PerformClick.run(View.java:9080)
在android.os.Handler.handleCallback(Handler.java:587)
在android.os.Handler.dispatchMessage(Handler.java:92)
在android.os.Looper.loop(Looper.java:130)
在android.app.ActivityThread.main(ActivityThread.java:3768)
在java.lang.reflect.Method.invokeNative(本机方法)
在java.lang.reflect.Method.invoke(Method.java:507)
在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:878)
在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
在dalvik.system.NativeStart.main(本机方法)
code
如果(reptimer!= NULL){
如果(reptimer.isPlaying()){
reptimer.stop();
}
}
的onCreate reptimer是
reptimer = MediaPlayer.create(SoloIgra.this,R.raw.napeto);
根据Android的文档:IllegalStateException异常,如果内部播放引擎尚未初始化或已被释放
所以确保你的MediaPlayer正在初始化,您不使用公布的。
I published my app and on some phones like Galaxy Nexus or HTC Explorer where my APP crashes.
I tested on many phones and app worked perfectly.
Can you explain me why is this happening and how to fix it ?
ERROR
java.lang.IllegalStateException
at android.media.MediaPlayer.isPlaying(Native Method)
at com.mario.kvizoman.SoloIgra.novopitanjce(SoloIgra.java:922)
at com.mario.kvizoman.SoloIgra.onClick(SoloIgra.java:901)
at android.view.View.performClick(View.java:2485)
at android.view.View$PerformClick.run(View.java:9080)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3768)
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:878)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
at dalvik.system.NativeStart.main(Native Method)
CODE
if(reptimer!=null) {
if(reptimer.isPlaying()) {
reptimer.stop();
}
}
onCreate reptimer is
reptimer = MediaPlayer.create(SoloIgra.this, R.raw.napeto);
According to the Android documentation: "IllegalStateException if the internal player engine has not been initialized or has been released."
So ensure your MediaPlayer is initialized, and you don't use the released one.
这篇关于安卓java.lang.IllegalStateException MediaPlayer.isPlaying的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!