---你们比我更聪明!!!
我无法解决此错误。 由于空指针异常,我的应用程序崩溃了。
这是错误:
java.lang.ArrayIndexOutOfBoundsException: length=6; index=6
at net.miraath.anbiyaa.SimpleMusicStream.updateAudioInfo(SimpleMusicStream.java:524)
at net.miraath.anbiyaa.SimpleMusicStream.access$1400(SimpleMusicStream.java:30)
at net.miraath.anbiyaa.SimpleMusicStream$AudioInfoLoadTask.onPostExecute(SimpleMusicStream.java:651)
at net.miraath.anbiyaa.SimpleMusicStream$AudioInfoLoadTask.onPostExecute(SimpleMusicStream.java:596)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
10-25 12:36:30.275 1560-1560/net.miraath.anbiyaa E/Trace﹕ error opening trace file: No such file or directory (2)
10-25 12:36:30.275 1560-1560/net.miraath.anbiyaa D/AndroidRuntime﹕ Shutting down VM
10-25 12:36:30.275 1560-1560/net.miraath.anbiyaa W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xb2ed3288)
10-25 12:36:30.275 1560-1560/net.miraath.anbiyaa E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start service net.miraath.anbiyaa.PlayerService@b3962930 with null: java.lang.NullPointerException
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2507)
at android.app.ActivityThread.access$1900(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at net.miraath.anbiyaa.PlayerService.onStart(PlayerService.java:117)
at android.app.Service.onStartCommand(Service.java:450)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2490)
at android.app.ActivityThread.access$1900(ActivityThread.java:130)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Gere是我拉我的头发的地方:这个相同的代码适用于其他无线电并且不会崩溃!
任何想法???
这是代码:
audioTitle.setText(infos[0]);
listenerNomber.setText("" + getResources().getString(R.string.lable_listiner_nomber)+": " + infos[0]);
audioTotalTime.setText(infos[5] + "k");
if(!infos[6].equals(stationOldAudioTitle)){
((MiraathRadio)getApplication()).intNotification(stationTitle.getText(), stationTitle.getText(), infos[6], stationIndex);
stationOldAudioTitle = infos[6];
}
以下是来自playerserver.class文件的代码:
stationURL = intent.getStringExtra("stationURL");
stationName = intent.getStringExtra("stationName");
stationIndex = intent.getIntExtra("stationIndex",0);
CharSequence stationAudioTitle = intent.getStringExtra("stationAudioTitle");
更新:我忘记提及所有这一切中的一个键:当我在由于异常而弹出的系统对话框上没有按OK时,应用程序继续在后台运行。只有当我单击“确定”时,应用程序崩溃且应用程序关闭。
答案 0 :(得分:3)
我不知道infos
在哪里被初始化,但基于异常(java.lang.ArrayIndexOutOfBoundsException: length=6; index=6
),它的长度为6,因此infos[6]
不在数组边界。