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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:58:51+00:00 2026-05-26T04:58:51+00:00

I had previously coded an app with a location listener without access to a

  • 0

I had previously coded an app with a location listener without access to a real device. Now that I have a Gingerbread phone (2.3.3), as expected my app is a battery killer.

I started examining the effect of the update time and minimum distance arguments to requestLocationUpdates as the documentation says that these will affect battery drain.

I had wondered how just adjusting these parameters could affect the battery drain, as far as I could see the GPS would have to remain on, in order to know what distance the device had moved and only the actual process of notifying the app would change whilst the chip continued using power.

This article Understanding the LocationListener in Android put forward a credible explanation, indicating that the status would change to ‘temporarily unavailable’ and the GPS icon would disappear from the screen for a while, until such time as it was necessary to turn back on again according to the update period specified.

This doesn’t happen on my phone – the GPS icon stays on even with an update period of 90 seconds and I get no status changes and according to some of the posts at the end of the article, others find the same.

  • Do any users on SO experience the same thing with 2.3.3?

  • Or have Android given up on managing the GPS chip and expect users to write their own battery management regime for the GPS?

For info my minimum code to demonstrate this behaviour is shown below:

public class GpsTimeOutTestActivity extends Activity implements
        LocationListener {

    private LocationManager mLocMgr;
    private long mUpdatePeriod = 90000; // 90 seconds
    private float mMinDistance = 10.0f;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }

    @Override
    protected void onResume() {
        super.onResume();
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        mLocMgr = (LocationManager) getSystemService(LOCATION_SERVICE);
        mLocMgr.requestLocationUpdates(LocationManager.GPS_PROVIDER,
                mUpdatePeriod, mMinDistance, (LocationListener) this);
    }

    @Override
    protected void onPause() {
        mLocMgr.removeUpdates((LocationListener) this);
        super.onPause();
    }

    @Override
    public void onLocationChanged(Location loc) {
        String str = null;
        NumberFormat formatter = new DecimalFormat("##0.000");
        String fLat = formatter.format(loc.getLatitude());
        String fLon = formatter.format(loc.getLongitude());
        String provider = loc.getProvider();
        provider = (provider == null) ? "No provider" : provider;
        str = "Locn chg " + provider + " Lat/Lon " + fLat + "/" + fLon;
        if (loc.hasAccuracy())
            str+= " accy " + loc.getAccuracy();

        showSomeOutput(str);
    }

    @Override
    public void onProviderDisabled(String provider) {
        String str = "Prov disabled " + provider;
        showSomeOutput(str);
    }

    @Override
    public void onProviderEnabled(String provider) {
        String str = "Prov enabled " + provider;
        showSomeOutput(str);
    }

    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        String str = "Status chg " + provider;
        switch (status) {
        case android.location.LocationProvider.OUT_OF_SERVICE:
            str+= " OUT OF SERVICE";
            break;
        case android.location.LocationProvider.AVAILABLE:
            str+= " AVAILABLE";
            break;
        case android.location.LocationProvider.TEMPORARILY_UNAVAILABLE:
            str+= " TEMPORARILY UNAVAILABLE";
            break;
        default:
            str+= " UNKNOWN STATUS";
        }
        showSomeOutput(str);
    }

    private void showSomeOutput(String str) {
        Log.d("GPSTEST", str);
        EditText et = (EditText) findViewById(R.id.editText1);
        Editable existingText = et.getText();
        existingText.append("\n" + str);
    }
}

All comments will be gratefully received.

  • 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-26T04:58:52+00:00Added an answer on May 26, 2026 at 4:58 am

    If you dig into the innards of the GPS provider, you will find that Android tells the native drivers the minimum update time. The native drivers can then decide what to do – in my experience, they all disregard this and keep running full-throttle.

    This is annoying, but doesn’t exactly violate the javadocs:

    The frequency of notification may be controlled using the minTime and minDistance parameters. If minTime is greater than 0, the LocationManager could potentially rest for minTime milliseconds between location updates to conserve power

    (emphasis added)

    The solution is to only register your LocationListener as needed. If you need to target APIs before requestSingleUpdate was added, you have to register your listener and then unregister it when you are satisfied with the quality of the location. This will turn the GPS back off and save power.

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

Sidebar

Related Questions

I have an application that uses CoreData. I previously had a class named Marker
previously i had custom tableviewcell and was loading from Nib.in that i have specified
Previously we had desktop applications but given the fact that accessing the server (either
Previously, I had a class that wrapped an internal System.Collections.Generic.List<Item> (where Item is a
I'm looking into development standards fro JavaScript. I had previously used Doulgas Crockfords Javascript
I want to define a constant in objective-c. Previously I had the following function:
If this was previously talked about, I'm sorry, I had a hard time searching
Since CS3 doesn't have a web service component, as previous versions had, is there
From previous experience I had been under the impression that it's perfectly legal (though
In a previous job we had a classic ASP application that no one wanted

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.