UI components can only be modified from the UI thread.
Your task is running in a background thread, so you need to force the TextView
update to be done in the UI thread. You can achieve it with the Activity.runOnUiThread
method.
Try this:
public void run(){
runOnUiThread(new Runnable() {
@Override
public void run() {
risultato.setText("" + recorder.getMaxAmplitude());
}
});
}
instead of
public void run(){
risultato.setText(""+recorder.getMaxAmplitude());
}