I am developing a serialport application for knx modules in android. I can send and recieve commends to knx modulde. I want to change ui(for ex. button properties) when a message recieved from serialport. I tried it with handlers but i havent be able to change ui. help me plss.
@Override public void OnSerialsData(final byte[] buffer, final int size) { .... }
its my serialport listener function calling insine ReadThread. This thread is starting in differend package from my activity. I want to send a message in this method to main activity.
You can use Activity.runOnUiThread() to communicate with UI thread. Read more about Processes and Threads, especially about worker threads.
For example within your OnSerialsData
, you can call
mActivity.runOnUiThread(new Runnable() {
public void run() {
mActivity.mButton.setText("message arrived!");
}
}