Android Toast Messages not working
You're trying to display a Toast
in a background thread. You should do all your UI operations on the main UI thread.
The exception RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
can be a little cryptic for beginners but essentially it tells you that you're in a wrong thread.
To solve it, wrap the toast to e.g. runOnUiThread()
:
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(...).show();
}
});