I have the following code:
protected MyCallback getMyCallbackHandler() {
return new MyCallback() {
@Override
public void onReady() {
// DO STUFF
if (stuff!= null) {
mThread = new MyThread(stuff,MyActivity.this);
mThread.execute(mSensors.getLocation());
}
else {
Toast.makeText(MyActivity.this, "No target detected! Try again later.", Toast.LENGTH_LONG).show();
mSensors.registerCallback(null);
}
runOnUiThread(new Runnable(){
@Override
public void run() {
comp.setVisibility(View.VISIBLE);
}
});
}
};
}
The problem is that if stuff==null
when Toast.makeText(...).show()
is called, first the toast message doesn't appear and second the next lines seems to be not executed.
If I comment just the Toast
line, everything run as expected.
I tried to put as context MyActivity.this
, getParent().getApplicationContext()
and also getApplicationContext()
but it doesn't work.