app crashing with "Called From Wrong Thread Exception" app crashing with "Called From Wrong Thread Exception" android android

app crashing with "Called From Wrong Thread Exception"


Only the UI thread that created a view hierarchy can touch its views.

You are trying to change the text of the UI element in Non UI Thread, so it gives exception.Use runOnUiThread

 Timer t = new Timer(); t.schedule(new TimerTask() { public void run() {        timerInt++;        Log.d("timer", "timer");        runOnUiThread(new Runnable() {            @Override            public void run() {                timerDisplayPanel.setText("Time =" + timerInt + "Sec");            }        });    }}, 10, 1000);