Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/212.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 错误:接收广播意图时出错_Android_Android Intent_Indexoutofboundsexception_Android Broadcast - Fatal编程技术网

Android 错误:接收广播意图时出错

Android 错误:接收广播意图时出错,android,android-intent,indexoutofboundsexception,android-broadcast,Android,Android Intent,Indexoutofboundsexception,Android Broadcast,我从可用的wifi位置获取信号强度。当我运行程序时,我得到了输出。但是,当我点击刷新按钮时,我得到了错误,如堆栈跟踪中所述。 我知道,在我保留计数器按钮之前,它工作得很好,但是在我保留加号和减号按钮之后,只有当我点击刷新按钮时,我才会得到错误 你能帮帮我吗 堆栈跟踪: FATAL EXCEPTION: main java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.wifi.SCAN_RES

我从可用的wifi位置获取信号强度。当我运行程序时,我得到了输出。但是,当我点击刷新按钮时,我得到了错误,如堆栈跟踪中所述。 我知道,在我保留计数器按钮之前,它工作得很好,但是在我保留加号和减号按钮之后,只有当我点击刷新按钮时,我才会得到错误

你能帮帮我吗

堆栈跟踪:

FATAL EXCEPTION: main
 java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.wifi.SCAN_RESULTS flg=0x10000010 } in com.example.wifisignalstrength.MainActivity$1@410f98f8
android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:737)
android.os.Handler.handleCallback(Handler.java:605)
android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
android.app.ActivityThread.main(ActivityThread.java:4517)
java.lang.reflect.Method.invokeNative(Native Method)
java.lang.reflect.Method.invoke(Method.java:511)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)

dalvik.system.NativeStart.main(Native Method)
03-06 13:15:45.102: E/AndroidRuntime(7139): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
java.util.ArrayList.get(ArrayList.java:304)
com.example.wifisignalstrength.MainActivity$1.onReceive(MainActivity.java:202)
android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:728)

看看count==15分支。您正在尝试获取空ArrayList的第一个元素索引=0,因为您仅通过ArrayList arr=new ArrayList;,对其进行了初始化;,但它没有数据。将数据放入其中的唯一位置是count=5 branch。

MainActivity上有什么。java:202?@nik是行:String[]tempSplit1=arr.get0.split;请在这上面加上更多的代码line@nikis我编辑并保存了整个代码;仅在尝试获取它的else块之前的if块中存在。arr显然是空的。