I am trying to display a dialog in a non-Activity class. Basically, I detect an object in my app, I would like to display a dialog and then switch activities. I\'m getting a \"j
This is the exception you will get if you are performing any UI operation on any thread or from any background task. Also context.runOnUiThread
won't work.
Instead use:
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
mDialog.dismiss();
}
});
You can use the same for showing where activity
is the object of activity
.