Hi all, I am beginner in android java.currently, i am using the Tiny 210 development board. I would like to run a "serial receive code" in continuous loop along with all "GUI". When i implementing the while loop then nothing is working and i can only see " Black screen" and nothing is disply even it is not giving a o/p. please provide me a appropriate guide.
Implement While Loop Along with GUI Interface.
You need to create a thread that runs in the background. It is most likely that your current loop is running in the GUI thread which is not a good idea. You can use something like this. new Thread() { @Override public void run() { // You code in here } }.start();
Thanks Sir But sir i must need to observe the Serial port continuous because I receive the continuous data from the serial port at each 250ms. so how could i implement the GUI along with this small receive Method(Function). SO please tell me the best appropriate method to implement the function.
You do all the serial handling in a thread and store the data in a buffer etc. This buffer is then read by the foreground task and processes and displays the data. This is how I handle an I2C interface under Android. The thread simply loops around every 100ms and reads the ADC. I then store the resulting voltage read in an array. The GUI task has a timer that then updates the display every 250ms. It read the voltage, converts this to a scaled value and displays the information on the screen to the user. Dave..
That means sir All serial handling thread are in background task. Is that any requirement for Background service or Registering of service?
Create a thread like I showed you above and do all your serial in there. Write a class to handle your data and have functions to retrieve it.
i have create a thread like attachment that i have send. so please send me where i m making mistake.
You can't update the GUI within a thread unless you use runOnUiThread but why don't you just read in the data into an array or buffer and set a flag to show that it is available and then process this in the GUI thread.