I am doing an AsyncTask to call an API call in my application. And showing the API response as an Alert. I have written that API calls on home screen activity and showed that alert on top of the home screen. But if I moved from that activity to another activity, that alert visible once I back to the home screen. Not showing on top of all activities. So my requirement is to show that alert on top of all activities once that API is successful.
Alert code :
private void AlertSubmitted(String message) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.alertlayout, null);
dialogBuilder.setView(dialogView);
dialogBuilder.setCancelable(false);
TextView btn_ok = dialogView.findViewById(R.id.btn_ok);
TextView txt_dia = dialogView.findViewById(R.id.txt_dia);
txt_dia.setText(message);
if(subAlertDialog != null && subAlertDialog.isShowing()) {
return;
}
subAlertDialog = dialogBuilder.create();
subAlertDialog.show();
btn_ok.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
dbManager.deleteData();
text.setVisibility(View.GONE);
subAlertDialog.dismiss();
return false;
}
});
}
This function is called from protected void onPostExecute(String s).