Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9031033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:38:06+00:00 2026-06-16T07:38:06+00:00

I have a dialog that prompts users to enable gps location if it’s not

  • 0

I have a dialog that prompts users to enable gps location if it’s not enabled.

After opening the settings, and the user enableing gps, and pressing the back button from the location settings screen they come back to the app, but the dialog is still visible.

Here is the code for the button clicked.

    // On pressing Settings button
    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);
            dialog.dismiss();
        }

    });

My question is why does the dialog.dismiss() not close the dialog, I have also tried dialog.cancel() with same result. Is there something I should be doing after opening the settings screen?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:38:07+00:00Added an answer on June 16, 2026 at 7:38 am

    I have exactly this code in my Activity:

    private void showLocationDisabledInfo() {
        final Context c = this;
        AlertDialog.Builder builder = new AlertDialog.Builder(c);
        builder.setMessage("TEST");
        builder.setPositiveButton("OK", new OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                c.startActivity(intent);
            }
        });
        builder.setNeutralButton(R.string.cancel, null);
        builder.create().show();
    }
    

    and it does close the dialog automatically, no matter what button I click. It’s from my application, and it was tested on devices with APIs 8 and 10, and emulator running API 17. The only difference (possibly) between our codes is the value of mContext. Please provide the whole code responsible for setting up the dialog and the environment in which you’ve seen described behavior.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Dojo dialog that is opened when a user clicks on an
I have a Login dialog that can create an alert dialog when the user
We have a WiX fragment in a file SomeDialog.wxs that prompts the user for
I have used the jQuery dialog code so that I can prompt my user.
I have a modeless dialog box being generated which prompts users to open a
I have an AlertDialog that prompts user if they want to send data. What
I've developed a dialog box that prompts a user to enter his/her phone number
I have a dialog that I want to place within another dialog and position
I have a dialog that I show with <class>.ShowDialog() . It has an OK
I have a jQuery dialog that appears and loads an external page. In that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.