0

If the location is disabled I want to show box and stop the execution process until I turn ON the location and come back to my app. Please Help with necessary suggestions. function, alertDialog.setTitle("GPS Setting"); alertDialog.setMessage("GPS is not enabled. Do you want to go to settings menu?");

    alertDialog.setPositiveButton("OK          ", new DialogInterface.OnClickListener() {


        public void onClick(DialogInterface dialog, int which) {
            Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
            mContext.startActivity(intent);
        }
    });

    alertDialog.setNegativeButton("Cancel                                         ", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            Toast.makeText(mContext, "Sorry we cannot proceed", Toast.LENGTH_SHORT).show();
        }
    });

    alertDialog.show();// Showing Alert Message

1 Answers1

0

You should use ProgressDialog at https://developer.android.com/reference/android/app/ProgressDialog.html see this example:

private ProgressDialog progressDialog;

    public void cerrarSession() {
        try {
            showDialog();
            // do something
        } catch (InternetException e) {
            // some exception
            e.printStackTrace();
        }
    }

    private void showDialog() {
        progressDialog = new ProgressDialog(SavingsRequestsManager.getActivity());
        progressDialog.setCancelable(false);
        closeDialog();
        progressDialog.setMessage(SavingsRequestsManager.getActivity().getString(R.string.progress));
        progressDialog.show();
    }

    public void closeDialog() {
        if (progressDialog != null && progressDialog.isShowing()) {
            progressDialog.dismiss();
        }
    }
Ênio Abrantes
  • 302
  • 2
  • 11