我创建了一个暂停媒体播放器的按钮。我有7个不同的媒体文件,一个接一个地运行。现在,如果我点击我的暂停按钮,我就会遇到这些异常。
03-28 20:06:34.302: E/AndroidRuntime(3456): FATAL EXCEPTION: main
03-28 20:06:34.302: E/AndroidRuntime(3456): java.lang.IllegalStateException: Could not execute method of the activity
03-28 20:06:34.302: E/AndroidRuntime(3456): at android.view.View$1.onClick(View.java:3633)
03-28 20:06:34.302: E/AndroidRuntime(3456): at android.view.View.performClick(View.java:4240)
03-28 20:06:34.302: E/AndroidRuntime(3456): at android.view.View$PerformClick.run(View.java:17721)
03-28 20:06:34.302: E/AndroidRuntime(3456): at android.os.Handler.handleCallback(Handler.java:730)
03-28 20:06:34.302: E/AndroidRuntime(3456): at android.os.Handler.dispatchMessage(Handler.java:92)
03-28 20:06:34.302: E/AndroidRuntime(3456): at android.os.Looper.loop(Looper.java:137)
03-28 20:06:34.302: E/AndroidRuntime(3456): at android.app.ActivityThread.main(ActivityThread.java:5103)
03-28 20:06:34.302: E/AndroidRuntime(3456): at java.lang.reflect.Method.invokeNative(Native Method)
03-28 20:06:34.302: E/AndroidRuntime(3456): at java.lang.reflect.Method.invoke(Method.java:525)
03-28 20:06:34.302: E/AndroidRuntime(3456): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
03-28 20:06:34.302: E/AndroidRuntime(3456): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
03-28 20:06:34.302: E/AndroidRuntime(3456): at dalvik.system.NativeStart.main(Native Method)
03-28 20:06:34.302: E/AndroidRuntime(3456): Caused by: java.lang.reflect.InvocationTargetException
03-28 20:06:34.302: E/AndroidRuntime(3456): at java.lang.reflect.Method.invokeNative(Native Method)
03-28 20:06:34.302: E/AndroidRuntime(3456): at java.lang.reflect.Method.invoke(Method.java:525)
03-28 20:06:34.302: E/AndroidRuntime(3456): at android.view.View$1.onClick(View.java:3628)
03-28 20:06:34.302: E/AndroidRuntime(3456): ... 11 more
03-28 20:06:34.302: E/AndroidRuntime(3456): Caused by: java.lang.NullPointerException
03-28 20:06:34.302: E/AndroidRuntime(3456): at de.basti12354.tage.uebungen.Tag1.verlaufKlick(Tag1.java:112)
03-28 20:06:34.302: E/AndroidRuntime(3456): ... 14 more
我的verlaufKlick方法:
public void verlaufKlick(View view) {
if (uebung.isPlaying()) {
uebung.pause();
}
if (uebung2.isPlaying()) {
uebung2.pause();
}
if (uebung3.isPlaying()) {
uebung3.pause();
}
if (uebung4.isPlaying()) {
uebung4.pause();
}
if (uebung5.isPlaying()) {
uebung5.pause();
}
if (uebung6.isPlaying()) {
uebung6.pause();
}
if (uebung7.isPlaying()) {
uebung7.pause();
} else {
uebung.start();
}
}