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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:09:53+00:00 2026-05-22T16:09:53+00:00

I am developing an Android application which consists a few activities. I want to

  • 0

I am developing an Android application which consists a few activities.
I want to get updates from the GPS (onLocationChanged, onProviderDisabled, onProviderEnabled, onStatusChanged) no matter in which activity the user is currently using.

Where should I implement the LocationListener in order to get such a behaviour?

This is the class I have created:

public class MyLocationListener implements LocationListener{

private LocationManager locationManager;
private String provider;

    @Override
public void onLocationChanged(Location locationGPS) {

    //do something
}

@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
    // TODO Auto-generated method stub

}

@Override
public void onProviderEnabled(String provider) {
    Log.i("===========================", "==============================");
    Log.i("onProviderEnabled", "==============================");
    Log.i("===========================", "==============================");

}

@Override
public void onProviderDisabled(String provider) {

    Log.i("===========================", "==============================");
    Log.i("onProviderDisabled", "==============================");
    Log.i("===========================", "==============================");
}
  • 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-22T16:09:54+00:00Added an answer on May 22, 2026 at 4:09 pm

    Start the location listener on the activity you wants to start the gps. To start the GPS you can use

    LocationManager locationManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
    LocationListener locationListener = new CTLocationListener();
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 1.0f, locationListener);
    

    and to stop the GPS you can use

    locationManager.removeUpdates(locationListener);
    

    Its better you write the GPS start on the onCreate()/onStart() and the GPS remove on the onDestroy() of a service and use that service. Otherwise once you stop the GPS the chance of starting the GPS again is less than 50% in some devices.

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

Sidebar

Related Questions

I am developing an android application in which I want to get UDID of
Am developing android application which contains floating menu effect from left to right. I
I am developing an Android application which needs an image to be transmitted from
I am developing one android application which select wifi access point from list of
I developing an android application in which i want to integrate faceebook and twitter.
I am developing an android application in which I have passed a string from
I am developing an android application in which I want to slide images with
I am developing an android application which involves parsing.I want to pass parameters to
I am developing android application in which i want to convert html code in
I am developing an android application in which i have to show data from

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.