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 9172317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:19:01+00:00 2026-06-17T16:19:01+00:00

On my login activity, I check if the user has activated/ turned on their

  • 0

On my login activity, I check if the user has activated/ turned on their GPS.
If not, I simply display an AlertDialog asking the user to switch on the GPS.

From the AlertDialog I launch/start an Intent as follows:

Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(settingsIntent);

When pressing the back button from the System Settings the user returns to the phone’s home screen… i.e “closing the app”.

I have tried onActivityResult but to no avail.
Furthermore, I have read up on similar problems other users had but it proofed
pointless as most answers related back to using onActivityResult.

Can someone please shine some light on the matter?

Edit:
Here is the full code for the AlertDialog:

builder = new AlertDialog.Builder(this);
builder.setTitle("GPS Not Found");
builder.setMessage("Want To Enable?");

//Dialog - Yes option
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialogInterface, int i)
{
Intent settingsIntent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(settingsIntent,1);
}
});

//Dialog - No option                
builder.setNegativeButton("No", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialogInterface, int i)
{

}
});

//Show he dialog
builder.create().show();

Edit:
Here are the OnPause() and OnResume() methods. I simply check to see if the provider is still active and the same with the locationManager.
Neither “TEST 1” nor “TEST 2” gets printed when I go back from Settings.

@Override
protected void onResume()
{
  Log.i(ERRORTAG, "TEST 1");

  super.onResume();
  if(provider != null)
  {
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, refreshTime, refreshDistance, this);
    gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
  }
}


@Override
protected void onPause()
{
  Log.i(ERRORTAG, "TEST 2");


  super.onPause();
  if(locationManager != null)
  {
    locationManager.removeUpdates((LocationListener) this);
    gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
  }


  if(loginDialog != null)
  {
    loginDialog.dismiss();
  }
}
  • 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-17T16:19:02+00:00Added an answer on June 17, 2026 at 4:19 pm

    Sorted out the problem.
    In the manifest file, the activity had the tag noHistory="true" which (to my understanding) doesn’t add it to the stack.
    Hence can’t go “back” to the activity.

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

Sidebar

Related Questions

In my login activity...I am asking the username and password.. I want to check
As part of my login procedure I'm trying to check that the user has
My site has a timeout set, so after 15 minutes of in-activity a login
Plain and simple. I start an Activity and check if the phone has the
I want the login activity to start when the user starts the app but
I have a login activity which has recover login and register features. If you
I have a login method that connects to a server to check the user
I have a login page (an activity in Android), during which I run an
This activity is used for login. It post the username and password to a
I have login- and game-layout in my activity. I would use AndroidAnnotations in my

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.