Thursday, 15 August 2013

graph - Android Handler is not updating automatically, rather it update when i touch the screen? -


I am making graph of the data coming from Arduino via Bluetooth. I am implementing the Live Graph using the Graphview Library. I am using handler for dynamic graph purpose. The problem handler is not automatically updating the graph The graph is updated only when I touch the screen and then it still becomes.

  handler mHandler = new handler () {@Override public void handleMessage:   

Note that these two fuses are in two separate classes. (Message message) {// TODO auto generated method stub super. HandleMessage (msg); Switch (msg.) {Case Bluetooth. UCCCNACCT: Bluetooth.connectedTrade = New Bluetooth. ConnectedTrade (BluetoothSocket) msg.obj); Toast. Make Text (getApplicationContext (), "Connected!", 0). Show (); String s = "connect successfully"; Bluetooth.connectedThread.start (); break; Case bluetooth MESSAGE_READ: Byte [] readBuf = (Byte []) msg.obj; String strIncom = new string (readBuf, 0, 5); Create string with // byte array // lag D. ("Instinctincom", Strencom); If (strIncom.indexOf ('.') == 2 & amp; amp; amp; amp; amp; amp; InternetOf ('s') == 0} {strIncom = strIncom.replace ("s", " ); If (isFloatNumber (strIncom)) {Series.appendData (new graphview data (Article 2LastXValue, Double.parseDouble (strIncom)), AutoScrollX); //GraphView.updateViewLayout (Graphview, empty); // X-Axis control (article 2lostequality> gt; = exeview & lock == true) {Series.resetData (new graphviewdata [] {}); Graph2LastXValue = 0; } And Article 2LastXValue + = 0.1; If (lock == true) graphView.setViewPort (0, XView); Else graphView.setViewPort (graph2LastXValue-Xview, XView); // Refresh GraphView.removeView (graphView); GraphView.addView (graphView); } } break; }}

This is the function where the data handler is being sent.

  Public Zero Run () {Byte [] Buffer; // buffer store for stream int byte; // Bytes Reading () Returning to I / InputStream, an exception occurs only when (true) {try {sleep (30); } Grip (Interrupted E) E. {// TODO Auto-Generated Catch Block e.printStackTrace (); } Buffer = new byte [1024]; // Read InputStream bytes = mmInStream.read (buffer); // Send the received bytes to the UI activity mHandler.ShareNews (MESSAGE_READ, bytes-1, buffer) .endToTarget (); } Hold (IOException e) {break; }}}  


No comments:

Post a Comment