I have and android application in which I am initializing a third party library in the onCreate() of the main activity. Now when there is any runtime error in initialization of the library, My application will crash and at that point I want to show an AlertDialogue to the user saying "some error message" in the dialogue box. The problem is that when the application crashes, my alert dialogue is showing up but it is dismissed along with the application. I want it to be persisted even when the application crashes. Below is the code of alert dialogue which I used.
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setMessage("Error!")
.setCancelable(true)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
//do things
}
});
AlertDialog alert = builder.create();
alert.show();
Can anyone guide me in how to make that AlertDialogue independent of the activity, so that it doesn't require the app window. If not possible, then what other widgets, I can use or customize?