Looking at the error:
android.widget.Toast.<init>(Toast.java:99)
at android.widget.Toast.makeText(Toast.java:262)
It's saying your error is with displaying toasts.
You can only display toasts on the UI thread.
protected Void doInBackground(Void... unused) {
boolean auth=doLogin(user_id,password,tran);
System.out.println(auth);
Looper.prepare();
return null;// don't interact with the ui!
}
The above is happening on a background thread, and doLogin() is using toasts.
See this answer to find out how to call a toast from an async task.
You could also call Activity.runOnUiThread(Runnable r) and place your toast call inside that.
To make this DRY code, you could create a method called showToast(String text) that looks like this:
public void showToast(String text) {
try {
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(MainAcivity.this, text, Toast.LENGTH_LONG).show();
}
});
} catch (InterruptedException e) {
e.printStackTrace();
}
}