I have 2 fragments and one of them I'm trying to update some views after some data update. My views are updated fine when I remain in fragment when I have these views. After changed to another fragment my thread continues to work fine. But after I return for the first fragment my views can't be updated.
myThread = new Thread(){
@Override
public synchronized void run(){
while( true ){
try {
sleep( 2000 );
myActivity.runOnUiThread( new Runnable(){
@Override
public void run(){
updateViews();
}
});
} catch ( InterruptedException e ) {
e.printStackTrace();
}
}
}
};
This is the update function:
private void updateViews(){
textView.setText( _chronometerService.getTime() );
}
Notice my thread continues to update data, my issue is why views can't be updated.