Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to parse ' ' as integer in android
    primarykey
    data
    text
    <p>I have read so many articles but still don't get it.</p> <p>I have a serial data which is a String type and i want to compare it with an integer.</p> <p>This is the read serial data code:</p> <pre><code>case MESSAGE_READ: int i; byte[] readBuf = (byte[]) msg.obj; // construct a string from the valid bytes in the buffer String readMessage = new String(readBuf, 0, msg.arg1); Log.i(LOG_TAG, readMessage); mTextView.setText(readMessage); String [] numbers = readMessage.split("\n"); int [] intNumber = new int[numbers.length]; //List&lt;Integer&gt; integers = new ArrayList&lt;Integer&gt;(); for (String number : numbers) { //integers.add(Integer.valueOf(number.trim())); for (i=0;i&lt;numbers.length;i++){ intNumber[i] = Integer.valueOf(number.trim()); if (intNumber[i]&lt;0 || intNumber[i]&gt;95){ //Some Actions } } } break; </code></pre> <p>And the LogCat shows:</p> <pre><code>05-06 17:28:06.919: D/BluetoothReadService(15090): connected 05-06 17:28:06.919: D/BluetoothReadService(15090): create ConnectedThread 05-06 17:28:06.929: D/BluetoothReadService(15090): setState() 2 -&gt; 3 05-06 17:28:06.949: I/BluetoothReadService(15090): BEGIN mConnectedThread 05-06 17:28:06.969: I/HBAS(15090): MESSAGE_STATE_CHANGE: 3 05-06 17:28:07.079: I/HBAS(15090): 24 05-06 17:28:07.079: I/HBAS(15090): 25 05-06 17:28:07.079: I/HBAS(15090): 26 05-06 17:28:07.079: I/HBAS(15090): 27 05-06 17:28:07.079: I/HBAS(15090): 28 05-06 17:28:07.079: I/HBAS(15090): 29 05-06 17:28:07.079: I/HBAS(15090): 0 05-06 17:28:07.079: I/HBAS(15090): 1 05-06 17:28:07.079: I/HBAS(15090): 2 05-06 17:28:07.079: I/HBAS(15090): 3 05-06 17:28:07.079: I/HBAS(15090): 4 05-06 17:28:07.079: I/HBAS(15090): 5 05-06 17:28:07.079: I/HBAS(15090): 6 05-06 17:28:07.079: I/HBAS(15090): 7 05-06 17:28:07.079: I/HBAS(15090): 8 05-06 17:28:07.079: I/HBAS(15090): 9 05-06 17:28:07.079: I/HBAS(15090): 10 05-06 17:28:07.079: I/HBAS(15090): 11 05-06 17:28:07.079: I/HBAS(15090): 12 05-06 17:28:07.079: I/HBAS(15090): 13 05-06 17:28:07.079: I/HBAS(15090): 14 05-06 17:28:07.079: I/HBAS(15090): 15 05-06 17:28:07.079: I/HBAS(15090): 16 05-06 17:28:07.079: I/HBAS(15090): 17 05-06 17:28:07.079: I/HBAS(15090): 18 05-06 17:28:07.079: I/HBAS(15090): 19 05-06 17:28:07.079: I/HBAS(15090): 20 05-06 17:28:07.079: I/HBAS(15090): 21 05-06 17:28:07.079: I/HBAS(15090): 22 05-06 17:28:07.079: I/HBAS(15090): 23 05-06 17:28:07.079: I/HBAS(15090): 24 05-06 17:28:07.079: I/HBAS(15090): 25 05-06 17:28:07.079: I/HBAS(15090): 26 05-06 17:28:07.079: I/HBAS(15090): 27 05-06 17:28:07.079: I/HBAS(15090): 28 05-06 17:28:07.079: I/HBAS(15090): 29 05-06 17:28:07.079: I/HBAS(15090): 0 05-06 17:28:07.079: I/HBAS(15090): 1 05-06 17:28:07.079: I/HBAS(15090): 2 05-06 17:28:07.079: I/HBAS(15090): 3 05-06 17:28:07.079: I/HBAS(15090): 4 05-06 17:28:07.079: I/HBAS(15090): 5 05-06 17:28:07.079: I/HBAS(15090): 6 05-06 17:28:07.079: I/HBAS(15090): 7 05-06 17:28:07.079: I/HBAS(15090): 8 05-06 17:28:07.079: I/HBAS(15090): 9 05-06 17:28:07.079: I/HBAS(15090): 10 05-06 17:28:07.079: I/HBAS(15090): 11 05-06 17:28:07.079: I/HBAS(15090): 12 05-06 17:28:07.079: I/HBAS(15090): 13 05-06 17:28:07.079: I/HBAS(15090): 14 05-06 17:28:07.079: I/HBAS(15090): 15 05-06 17:28:07.079: I/HBAS(15090): 16 05-06 17:28:07.079: I/HBAS(15090): 17 05-06 17:28:07.079: I/HBAS(15090): 18 05-06 17:28:07.079: I/HBAS(15090): 19 05-06 17:28:07.079: I/HBAS(15090): 20 05-06 17:28:07.079: I/HBAS(15090): 21 05-06 17:28:07.079: I/HBAS(15090): 22 05-06 17:28:07.079: I/HBAS(15090): 23 05-06 17:28:07.079: I/HBAS(15090): 24 05-06 17:28:07.079: I/HBAS(15090): 25 05-06 17:28:07.079: I/HBAS(15090): 26 05-06 17:28:07.079: I/HBAS(15090): 27 05-06 17:28:07.079: I/HBAS(15090): 28 05-06 17:28:07.079: I/HBAS(15090): 29 05-06 17:28:07.079: I/HBAS(15090): 0 05-06 17:28:07.079: I/HBAS(15090): 1 05-06 17:28:07.079: I/HBAS(15090): 2 05-06 17:28:07.079: I/HBAS(15090): 3 05-06 17:28:07.079: I/HBAS(15090): 4 05-06 17:28:07.079: I/HBAS(15090): 5 05-06 17:28:07.079: I/HBAS(15090): 6 05-06 17:28:07.079: I/HBAS(15090): 7 05-06 17:28:07.079: I/HBAS(15090): 8 05-06 17:28:07.079: I/HBAS(15090): 9 05-06 17:28:07.079: I/HBAS(15090): 10 05-06 17:28:07.079: I/HBAS(15090): 11 05-06 17:28:07.079: I/HBAS(15090): 12 05-06 17:28:07.079: I/HBAS(15090): 13 05-06 17:28:07.079: I/HBAS(15090): 14 05-06 17:28:07.079: I/HBAS(15090): 15 05-06 17:28:07.079: I/HBAS(15090): 16 05-06 17:28:07.079: I/HBAS(15090): 17 05-06 17:28:07.079: I/HBAS(15090): 18 05-06 17:28:07.079: I/HBAS(15090): 19 05-06 17:28:07.079: I/HBAS(15090): 20 05-06 17:28:07.079: I/HBAS(15090): 21 05-06 17:28:07.079: I/HBAS(15090): 22 05-06 17:28:07.079: I/HBAS(15090): 23 05-06 17:28:07.079: I/HBAS(15090): 24 05-06 17:28:07.079: I/HBAS(15090): 25 05-06 17:28:07.079: I/HBAS(15090): 26 05-06 17:28:07.079: I/HBAS(15090): 27 05-06 17:28:07.079: I/HBAS(15090): 28 05-06 17:28:07.079: I/HBAS(15090): 29 05-06 17:28:07.079: I/HBAS(15090): 0 05-06 17:28:07.079: I/HBAS(15090): 1 05-06 17:28:07.079: I/HBAS(15090): 2 05-06 17:28:07.079: I/HBAS(15090): 3 05-06 17:28:07.079: I/HBAS(15090): 4 05-06 17:28:07.079: I/HBAS(15090): 5 05-06 17:28:07.079: I/HBAS(15090): 6 05-06 17:28:07.079: I/HBAS(15090): 7 05-06 17:28:07.079: I/HBAS(15090): 8 05-06 17:28:07.079: I/HBAS(15090): 9 05-06 17:28:07.079: I/HBAS(15090): 10 05-06 17:28:07.079: I/HBAS(15090): 11 05-06 17:28:07.079: I/HBAS(15090): 12 05-06 17:28:07.969: I/HBAS(15090): 1 05-06 17:28:08.029: I/HBAS(15090): 3 05-06 17:28:09.019: I/HBAS(15090): 14 05-06 17:28:09.979: I/HBAS(15090): 1 05-06 17:28:10.029: I/HBAS(15090): 5 05-06 17:28:10.989: I/HBAS(15090): 16 05-06 17:28:12.009: I/HBAS(15090): 17 05-06 17:28:12.999: I/HBAS(15090): 18 05-06 17:28:13.999: I/HBAS(15090): 19 05-06 17:28:14.999: I/HBAS(15090): 20 05-06 17:28:16.009: I/HBAS(15090): 21 05-06 17:28:17.009: I/HBAS(15090): 22 05-06 17:28:18.009: I/HBAS(15090): 23 05-06 17:28:19.019: I/HBAS(15090): 24 05-06 17:28:20.019: I/HBAS(15090): 25 05-06 17:28:21.029: I/HBAS(15090): 26 05-06 17:28:22.029: I/HBAS(15090): 27 05-06 17:28:23.029: I/HBAS(15090): 28 05-06 17:28:24.039: I/HBAS(15090): 29 05-06 17:28:25.039: I/HBAS(15090): 0 05-06 17:28:26.029: I/HBAS(15090): 1 05-06 17:28:26.069: I/HBAS(15090): 05-06 17:28:26.069: D/AndroidRuntime(15090): Shutting down VM 05-06 17:28:26.069: W/dalvikvm(15090): threadid=1: thread exiting with uncaught exception (group=0x40018578) 05-06 17:28:26.079: E/AndroidRuntime(15090): FATAL EXCEPTION: main 05-06 17:28:26.079: E/AndroidRuntime(15090): java.lang.NumberFormatException: unable to parse '' as integer 05-06 17:28:26.079: E/AndroidRuntime(15090): at java.lang.Integer.parseInt(Integer.java:362) 05-06 17:28:26.079: E/AndroidRuntime(15090): at java.lang.Integer.parseInt(Integer.java:332) 05-06 17:28:26.079: E/AndroidRuntime(15090): at java.lang.Integer.valueOf(Integer.java:506) 05-06 17:28:26.079: E/AndroidRuntime(15090): at com.android.hbas.FinalSetting$1.handleMessage(FinalSetting.java:362) 05-06 17:28:26.079: E/AndroidRuntime(15090): at android.os.Handler.dispatchMessage(Handler.java:99) 05-06 17:28:26.079: E/AndroidRuntime(15090): at android.os.Looper.loop(Looper.java:130) 05-06 17:28:26.079: E/AndroidRuntime(15090): at android.app.ActivityThread.main(ActivityThread.java:3687) 05-06 17:28:26.079: E/AndroidRuntime(15090): at java.lang.reflect.Method.invokeNative(Native Method) 05-06 17:28:26.079: E/AndroidRuntime(15090): at java.lang.reflect.Method.invoke(Method.java:507) 05-06 17:28:26.079: E/AndroidRuntime(15090): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 05-06 17:28:26.079: E/AndroidRuntime(15090): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625) 05-06 17:28:26.079: E/AndroidRuntime(15090): at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>At start it worked but at some time it FC because of ' ' thing. So any solution??? Thanks for the advice..</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload