I will try to keep it simple:
In my main activity I make a handler:
public class ARViewer extends ARDisplayActivity {
public final MHandler mHandler = new MHandler(this);
public void onCreate(Bundle savedInstanceState) {
...
The class MHandler:
public final class MHandler extends Handler{
//main activity
private ARViewer arnv;
public MHandler(ARViewer arnv){
this.arnv = arnv;
}
@Override
public void handleMessage(Message msg) {
...
case H_RR :
arnv.setContentView(R.layout.routeplanner);
break;
...
super.handleMessage(msg);
}
}
But if I call the handleMessage method from a callback function in a other Class, definitely from a other thread, I still get the exception message: CalledFromWrongThreadException (Only the original thread that created a view hierarchy can touch its views)
:
public void rFound(Route route) {
Message msg = new Message();
msg.what = MHandler.H_RR;
ARViewer.arnv.mHandler.handleMessage(msg);
}