title: converting string to int or boolean inside handler
body: <p>Im trying to build an engine monitor, I am receiving a string of data from arduino via bluetooth. I created the bluetoothIn handler that reads and splits the string into variables. I need to convert the variables from string to integer or double but doing that inside the handler causes the app to crash. I am aware that the handler returns  thats why the app crashes. So how would I extract the data from the handler?</p>
  
  <pre><code>bluetoothIn = new Handler() {
    public void handleMessage(android.os.Message msg) {
      if (msg.what == handlerState) {                                     //if message is what we want
        String readMessage = (String) msg.obj;                                                                // msg.arg1 = bytes from connect thread
        recDataString.append(readMessage);                                      //keep appending to string until ~
        int endOfLineIndex = recDataString.indexOf("~");                    // determine the end-of-line
        if (endOfLineIndex &gt; 0) {                                           // make sure there data before ~
          String dataInPrint = recDataString.substring(0, endOfLineIndex);    // extract string
          txtString.setText("Data Received = " + dataInPrint);
          int dataLength = dataInPrint.length();
          txtStringLength.setText("String Length = " + String.valueOf(dataLength));
  
          if (recDataString.charAt(0) == '#') {
            //datapro=String.valueOf(recDataString);
            //Message msg = Message.obtain();
            //msg.obj=datapro;
            //msg.setTarget(Handler2);
            //msg.sendToTarget();
            sensor0 = recDataString.substring(1, 5);             //get sensor value from string between indices 1-5
            sensor1 = recDataString.substring(6, 10);
            sensor2 = recDataString.substring(11, 15);
            sensor3 = recDataString.substring(16, 20);
  
            RPM = (Double.valueOf(sensor2) * 1000);
            V = ((RPM / ratio[box]) / FD) * (0.118);
            status = Integer.valueOf(sensor3);
  
            sensorView0.setText(" Battery Voltage = " + sensor0 + "V");    //update the textviews with sensor values
            sensorView1.setText(" Velocity = " + String.valueOf(V));
            sensorView2.setText("RPM=" + String.valueOf(RPM));
            sensorView3.setText(String.valueOf(status));
  
          }
  
          recDataString.delete(0, recDataString.length());                    //clear all string data
          // strIncom =" ";
          dataInPrint = " ";
        }
      }
    }
  };
  </code></pre>
  
  <p>Logcat:</p>
  
  <pre><code>04-26 17:07:51.288: I/art(13924): Late-enabling -Xcheck:jni
  04-26 17:07:51.413: D/BluetoothAdapter(13924): 72305841: getState() :  mService = null. Returning STATE_OFF
  04-26 17:07:51.426: D/OpenGLRenderer(13924): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
  04-26 17:07:51.435: D/Atlas(13924): Validating map...
  04-26 17:07:51.500: I/Adreno-EGL(13924): &lt;qeglDrvAPI_eglInitialize:379&gt;: QUALCOMM Build: 01/15/15, ab0075f, Id3510ff6dc
  04-26 17:07:51.501: I/OpenGLRenderer(13924): Initialized EGL, version 1.4
  04-26 17:07:51.521: D/OpenGLRenderer(13924): Enabling debug mode 0
  04-26 17:08:45.253: W/BluetoothAdapter(15820): getBluetoothService() called with no BluetoothManagerCallback
  04-26 17:08:51.273: D/AndroidRuntime(15820): Shutting down VM
  04-26 17:08:51.273: D/AndroidRuntime(15820): --------- beginning of crash
  04-26 17:08:51.275: E/AndroidRuntime(15820): FATAL EXCEPTION: main
  04-26 17:08:51.275: E/AndroidRuntime(15820): Process: com.example.alpha_version, PID: 15820
  04-26 17:08:51.275: E/AndroidRuntime(15820): java.lang.NumberFormatException: Invalid int: "0.00"
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at java.lang.Integer.invalidInt(Integer.java:138)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at java.lang.Integer.parse(Integer.java:410)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at java.lang.Integer.parseInt(Integer.java:367)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at java.lang.Integer.parseInt(Integer.java:334)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at java.lang.Integer.valueOf(Integer.java:525)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at com.example.alpha_version.Main$1.handleMessage(Main.java:95)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at android.os.Handler.dispatchMessage(Handler.java:102)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at android.os.Looper.loop(Looper.java:135)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at android.app.ActivityThread.main(ActivityThread.java:5254)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at java.lang.reflect.Method.invoke(Native Method)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at java.lang.reflect.Method.invoke(Method.java:372)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
  04-26 17:08:51.275: E/AndroidRuntime(15820):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  04-26 17:08:57.542: I/Process(15820): Sending signal. PID: 15820 SIG: 9
  04-26 17:08:57.942: D/OpenGLRenderer(15987): Use EGL_SWAP_BEHAVIOR_PRESERVED: true
  04-26 17:08:57.948: D/Atlas(15987): Validating map...
  04-26 17:08:58.010: I/Adreno-EGL(15987): &lt;qeglDrvAPI_eglInitialize:379&gt;: QUALCOMM Build: 01/15/15, ab0075f, Id3510ff6dc
  04-26 17:08:58.012: I/OpenGLRenderer(15987): Initialized EGL, version 1.4
  04-26 17:08:58.066: D/OpenGLRenderer(15987): Enabling debug mode 0
  </code></pre>