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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:09:35+00:00 2026-05-30T11:09:35+00:00

Here are snippets of my code: private class NoGpsLock implements Runnable { public void

  • 0

Here are snippets of my code:

private class NoGpsLock implements Runnable {
    public void run() {
      if (gps == null) {
        Toast toast = Toast.makeText(getApplicationContext(), "Unable to find GPS lock", Toast.LENGTH_LONG);
        toast.show();
        if (locManager != null) {
          locManager.removeUpdates(locListener);
        }
      }
    }
  }

Called by

try {
  locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, MIN_TIME, MIN_DIST, locListener);
} catch (Exception ex) {
}
Handler gpsHandler = new Handler();
gpsHandler.postDelayed(new NoGpsLock(), 15000); //15seconds

From what I understand, removeUpdates() is supposed to stop the GPS receiving updates. I tried this on the emulator and on 2 devices; on the emulator, it does stop the app from receiving further location changes. However, on the actual devices, the icon for “Receiving location data from GPS” keeps showing up and drains the battery (which I assume indicates that the app/phone keeps on looking for a location and unable to, since I’m indoors). How do I stop the GPS from trying to find a location?

EDIT: I want my app to stop trying to find location after a period of time, and then maybe restart the GPS again later.

  • 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-30T11:09:36+00:00Added an answer on May 30, 2026 at 11:09 am

    removeUpdates(locationListener) is supposed to stop that blinking GPS icon. If it isn’t doing that, the best suggestion I can offer is that maybe there are there are other listener instances still registered with your locationManager? A forgotten for-loop could have attached other listener instances. As a brute-force developer I’d do removeUpdates() multiple times to see if that has any effect.

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

Sidebar

Related Questions

Here is a VB.NET code snippet Public Class OOPDemo Private _strtString as String Public
First of all here are some code snippets: public void startThread() { this.animationThread =
Here's the code snippet: public static void main (String[]arg) { char ca = 'a'
Here is my code (just a snippet to expose the problem) : public class
Let me first put the code snippets here. I am just using the ASP.NET
I want to understand if code snippets are what I am looking for here.
I use UDP Sokckts in my client application. Here are some code snippets: SendIP
here is the relevent code snippet: public static Rand searchCount (int[] x) { int
Greetings all, I have a code snippet as follows : class AppCtx { private:
here's the snippet in java: class C { private static int c = 0;

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.