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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:44:23+00:00 2026-06-03T05:44:23+00:00

If we want to get a single GPS fix in Android we actually use

  • 0

If we want to get a single GPS fix in Android we actually use the known function requestSingleUpdate() with LocationManager.GPS_PROVIDER, right?

Now i was exactly doing this in my function getLocation() with GPS turned on, but the device is not automatically going to establish a connection, unless i manually turn off the GPS and then turn it on again. requestSingleUpdate() for the network provider works flawlessly, i just don’t know why this doesn’t go for the GPS fixing.

Here is a part from my source code:

getLocation() is run by another object with a timer every 2 minutes.. in getLocation() if the GPS and Network are on, it tries to get a GPS fix in the first minute and then it fetches the network location if there is no GPS fix available.

public boolean getLocation() {
    // DEBUG
    Log.d("GPS Connection", "Entering getLocation()");
    gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
    networkEnabled = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    if(!gpsEnabled && !networkEnabled)
        return false;

    if(gpsEnabled && networkEnabled) {
        // DEBUG
        Log.d("GPS Connection", "Request GPS Data");
        locationManager.requestSingleUpdate(LocationManager.GPS_PROVIDER, gpsLocationListener, Looper.getMainLooper());
        gpsGetLocationTimeout = new Timer();
        gpsGetLocationTimeout.schedule(new GetNetworkLocation(), GPS_MAX_CONNECTION_TIME_MS);
    }

    ...
  • 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-03T05:44:25+00:00Added an answer on June 3, 2026 at 5:44 am

    From the Android documentation:

    It may take a while to receive the most recent location. If an
    immediate location is required, applications may use the
    getLastKnownLocation(String) method. In case the provider is disabled
    by the user, the update will not be received, and the
    onProviderDisabled(String) method will be called. As soon as the
    provider is enabled again, the onProviderEnabled(String) method will
    be called and location updates will start again.

    GPS can take a long time to get from a cold start. You may never get a GPS if you are indoors, in a parking structure, surrounded by tall buildings, have a crappy phone, or if the GPS Satellite Gods are in a funny mood.

    In some applications, we will do something like request a GPS location, then if it hasn’t arrived after 60 seconds, cancel the request so that we don’t kill the phone’s battery with a GPS RX left on semi-permanently.

    You can request last known location and check its age and decide if it is recent enough to use. Network location is fast and cheap (in terms of battery use) and a good strategy is to use network location until you get GPS.

    My experience coding GPS in Android is that the GPS is going to do what it wants to do which is in many ways not what the documentation leads you to expect. GPS needs to be treated as something which may or may not be available and the logic of your program can be designed to handle that.

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

Sidebar

Related Questions

I am using LocationManager to get a single location fix: public class MyActivity extends
I want to get the single digits from two digits.for example if 36 I
I want to get data from two tables with single Entity class. How?? public
Trying to do this with a single query, but want to get a list
I want to get a single object from my Core Data datastore, here is
I want to get notifications when user single tap or double tap on imageView
How to get single value from {:country_code=>FR, :country_code1=>FRE, :country_name=>France, :region=>11, :city=>Paris} ? I want
I want to get a single property(blob) from a single entity (by Id). I
I have a scenario where I want to get the single sign on experience
I have a number like 99 now I need to get a single digit

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.