I'm developing an android application in which I have a thread that continuously generates data to be appended in a Textview
, I use an Handler
for this but after 1 or 2 secs my app just freezes.
The code is something like:
private class UpdateTextRunnable implements Runnable
{
private String mBuffer = "";
public void addLine( String line ) {
mBuffer += line + "\n";
}
@Override
public void run(){
mTextView.setText( mBuffer );
}
}
and in the thread a method from a custom interface is called every 0.5/1 sec :
public void onMyCustomEvent( String data )
{
// mUpdater is an instance of UpdateTextRunnable
mUpdater.addLine( data );
// mHandler is an instance of Handler inside the main activity
mHandler.post( mUpdater );
}
What am I doing wrong ? :) Thanks