public class IdAsync extends AsyncTask<String, Void, Void> {
AlertDialog alertDialog = new AlertDialog.Builder(MainClass.this).create();
protected Void doInBackground(String... params) {
.
.
alertDialog.setTitle("Reset...");
alertDialog.setMessage("R u sure?");
alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
//here you can add functions
} });
alertDialog.show();
.
.}
This gives Runtime error
E/AndroidRuntime(16606): at android.app.Dialog.show(Dialog.java:241)
The method doInBackground is used to do background tasks. To update the UI in AsyncTask use onProgressUpdate method. Refer http://developer.android.com/reference/android/os/AsyncTask.html#onProgressUpdate(Progress…)