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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:16:23+00:00 2026-05-25T03:16:23+00:00

I’ve written a Small Google Maps Application, which makes me a few Problems. The

  • 0

I’ve written a Small Google Maps Application, which makes me a few Problems.

The LocationListener i wrote, overrides the onProviderDisabled Method to call an Activity, where the User can Switch on his GPS.

This do the Job well, but one Problem is still there. If i close the Maps_Activity and after that shut down the GPS, it seems, that the Listener is already running, because the Activity (the one who says me, that the GPS is not running) still pops up.

The LocationListner as followed:

public class LocationUpdateHandler implements LocationListener {

    @Override
    public void onLocationChanged(Location location) {

        mMyLocationOverlay.enableMyLocation();
        mMyLocationOverlay.runOnFirstFix(new Runnable() {

            @Override
            public void run() {
                mMapView.getController().animateTo(
                        mMyLocationOverlay.getMyLocation());
            }
        });
    }

    @Override
        public void onProviderDisabled(String provider) {
        Intent i = new Intent(MapActivity.this, NoGpsActivity.class);
        startActivity(i);
    }

    @Override
    public void onProviderEnabled(String provider) {
        Toast.makeText(getApplicationContext(), "GPS ready", Toast.LENGTH_LONG).show();
    }

}

The NoGPSAcivity.class as followed:

public class NoGpsActivity extends Activity {

private OnClickListener mEnableGPSListener = new OnClickListener() {

    @Override
    public void onClick(View v) {
        startActivityForResult(new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS), 0);

    }
};

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gps_not_available_overlay);

        Button mEnableGPS = (Button)findViewById(R.id.enablegps_button);

        mEnableGPS.setOnClickListener(mEnableGPSListener);

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if(resultCode == 0){
        finish();
    }
}



 }

Thank you for your help!

  • 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-05-25T03:16:24+00:00Added an answer on May 25, 2026 at 3:16 am

    In your onDestroy() method you need to call removeUpdates(locationListener) so it will stop receiving updates.

    Also another thing to watch out for is that the “Home” key in Android generally means “minimize” (leaving your program in the background) while the “Back” key means “close”. So if your hitting home to exit, most likely it is still running.

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

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

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.