try the command
not sure if all buttons cancel ... I heard that messages about the onCancel () method are not working properly. my solution is only to make a regular button in the call-back dialog box whenever the button is clicked.
private void createCancelProgressDialog(String title, String message, String buttonText) { cancelDialog = new ProgressDialog(this); cancelDialog.setTitle(title); cancelDialog.setMessage(message); cancelDialog.setButton(buttonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) {
then just use the simple call method from another place in your activity.
createCancelProgressDialog("Loading", "Please wait while activity is loading", "Cancel");
a fairly simple solution, but it does the trick;) itβs also easy to note that cancelDialog is an action clearing variable, if you do not need to call it from another place, then you should leave by simply limiting the scope of the variable to this method.
source share