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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:08:45+00:00 2026-05-26T03:08:45+00:00

I am trying to implement a gps location listener that will stay on and

  • 0

I am trying to implement a gps location listener that will stay on and continuously update in the background. I realize this is bad practice but I am doing this for testing purposes. Right now I have a location listener that gets called with getGPS(). It can also be killed with killGPS().

It works perfectly when im walking around and I click my get gps button which takes the latitude and longitude from my location parameter which I get from

    GPSActivity.getGPS();
    loc_listener = GPSActivity.loc_listener;
     locationManager = (LocationManager)
     getSystemService(LOCATION_SERVICE);
     locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
     0, 0, loc_listener);
    location=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

However in the background, sometimes it will say I’m still at my apartment even though I’ve been out for 3hours!
Why is my location listener not updating itself even though it turns on to find a new location every 10 mins?

Thanks

package com.cellphone;

import android.app.Activity;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;

public class GPSActivity extends Activity{
    public static LocationListener loc_listener = null;

    public static void getGPS() {
        if (loc_listener == null) {
            loc_listener = new LocationListener() {

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

                }

                @Override
                public void onProviderEnabled(String provider) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onProviderDisabled(String provider) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onLocationChanged(Location location) {
                    // TODO Auto-generated method stub

                }
            };
        }

    }

    public static void killGPS(LocationManager locationManager) {
        if (locationManager != null && loc_listener != null) {
            locationManager.removeUpdates(loc_listener);
        }
    }

}
  • 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-26T03:08:46+00:00Added an answer on May 26, 2026 at 3:08 am

    for location poller, here is simple & working example:
    https://github.com/commonsguy/cwac-locpoll

    you can keep state of your app by adding a function in Application context. So to say, location poller can be aware of app-state and skip gps action if app is not active.

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

Sidebar

Related Questions

I'm trying to implement a thread so that I can send GPS coordinates in
I am trying to create an app that will obtain the users location via
I am trying to get the current location. For that I implement a LocationListener
Trying to implement a search similar to here .This searches properties based on city,locality,property
Trying to implement some nested loops that are spitting out good old nested html
I'm trying to develop an application that will simulate a route through Google's Navigation
I am working on a Widget which will get the Current GPS location and
I am trying to get GPS data without using map view.The code that I
I am trying to store the value of the GPS coordinates that are in
SetFocus I'm trying implement the above Se Focus code in a Class Library that

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.