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

  • Home
  • SEARCH
  • 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 9188425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:00:15+00:00 2026-06-17T20:00:15+00:00

I made a little gps app for some reason onLocationChanged not refreshing, it only

  • 0

I made a little gps app for some reason onLocationChanged not refreshing, it only run once, on app start.

Here is my code:

public BackgroundLocationService() {
        super("myintentservice");

        locManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

        Criteria crt = new Criteria();
        crt.setAccuracy(Criteria.ACCURACY_FINE);
        String bestProvider = locManager.getBestProvider(crt, true);

        boolean gps_enabled;
        boolean network_enabled;
        boolean best_enabled;

        gps_enabled = locManager.isProviderEnabled(LocationManager.GPS_PROVIDER);
        network_enabled = locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER);
        best_enabled = locManager.isProviderEnabled(bestProvider);


        if (best_enabled) {
            locManager.requestLocationUpdates(bestProvider, 15000, 20, locListener);
            Log.i(TAG, "Best enabled: " + bestProvider);
        } else {
            Log.i("Location Provider: ", "best not enabled: " + bestProvider);
            if (gps_enabled) {
                locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locListener);
                Log.i(TAG, "gps enabled!");
            }
            if (network_enabled) {
                locManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locListener);
                Log.i(TAG, "network enabled!");
            }
        }

    }



    class MyLocationListener implements LocationListener {
        public void onLocationChanged(Location location) {

            if (location != null) {

                //locManager.removeUpdates(locListener);
                longitude = Double.toString(location.getLongitude());
                latitude = Double.toString(location.getLatitude());

                Log.i(TAG,"Location has CHANGED!");
            }
        }
        public void onProviderDisabled(String arg) {}
        public void onProviderEnabled(String arg) {}
        public void onStatusChanged(String provider, int status, Bundle extras) {}
    }

The “Location has CHANGED!” message only shows once with each app start.
Im in an office but i can move at least 5-10 meters away from my position and ALL the providers are enabled so it must be Ok, isnt it?

Any ideas ?

  • 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-17T20:00:18+00:00Added an answer on June 17, 2026 at 8:00 pm

    When you register the location listener, you’re requesting updates with a min time of 15 seconds and a minimum distance of 20 meters. Since you’re inside an office, it’s unlikely that you’re able to get an accurate enough GPS fix to actually detect a move of 5-10 meters. Have you tried debugging outside? Similarly, if you enabled mock locations, send mock coordinates to the emulator to ensure your app acts as you expect when locations are updated.

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

Sidebar

Related Questions

if i made a little program in which i utilized some javafx code, when
I made a GPS based app, which works perfectly except for a little mistake.
I made some little programs with Swing-components in JRuby. Now I want to convert
I made this little function from code snippets around the net. It does what
I've made a little inline editor with some clean up logic. So if you
I have made a YUI module a little like the code shown below, which
So... I have some little flash graphs I made that pull data from an
So I have made a little piece of code that will insert and manipulate
I'm learning Objective-c and made a little practice app to take input from an
I made a little Windows Forms program to do some auto backup of some

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.