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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:28:41+00:00 2026-05-27T13:28:41+00:00

I have a problem with onLocationChanged event in Android. Here’s the triggering: case R.id.start:

  • 0

I have a problem with onLocationChanged event in Android. Here’s the triggering:

case R.id.start: {
    Points.add(overlay.getMyLocation()); // Points' type is ArrayList<GeoPoint>
    mgr.requestLocationUpdates(best, 0, 3, locationListener);
    }
    break;

And here’s the onLocationChanged method:

public void onLocationChanged(Location location) {
    i++;
    Points.add(overlay.getMyLocation());
    MapOverlay mapOverlay = new MapOverlay(Points.get(i-1), Points.get(i));
    map.getOverlays().add(mapOverlay); //does the drawing
    mMapController.animateTo(Points.get(i));
}

So, onLocationChanged is called only once and only after I press “start”. It’s supposed to be called automatically every time the location has changed, right? In my case, it’s not.
Please help me.

  • 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-27T13:28:41+00:00Added an answer on May 27, 2026 at 1:28 pm

    Problem seems to be solved.
    In onCreate, I added:

    Criteria crit = new Criteria();
    crit.setAccuracy(Criteria.ACCURACY_FINE);
    best = mgr.getBestProvider(crit, false);
    mgr.requestLocationUpdates(best, 0, 1, locationListener);
    

    onLocationChanged now looks like that:

    @Override
    public void onLocationChanged(Location location) {
        i++;
        nextPoint = overlay.getMyLocation();
        latitude = nextPoint.getLatitudeE6();
        longtitude = nextPoint.getLongitudeE6();
        lastPoint = new GeoPoint((int) latitude, (int) longtitude);
        Points.add(lastPoint);
        MapOverlay mapOverlay = new MapOverlay(Points.get(i - 1), Points.get(i));
        map.getOverlays().add(mapOverlay);
        mMapController.animateTo(Points.get(i));
        nextPoint = null;
        lastPoint = null;
    }
    

    Also, very important methods:

    @Override
    protected void onResume() {
        super.onResume();
        mgr.requestLocationUpdates(best, 10000, 1, locationListener);
    }
    
    @Override
    protected void onPause() {
        super.onPause();
        mgr.removeUpdates(locationListener);
    }
    

    And also some new permissions:

    <uses-permission android:name="android.permission.ACCESS_GPS" />
            <uses-permission android:name="android.permission.ACCESS_LOCATION" />
            <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
            <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
            <uses-permission android:name="android.permission.INTERNET" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem while sending messages from android to PC. Messages are send when
I still have problem with fetching first location on android. I am using Criteria
I have a little problem... I have made an Android application which extends the
I have some trobule using Google Maps API on Android. In onLocationChanged() I create
I have problem running my app on Android 2.3 (Gingerbread). The app has a
I have problem in uploading .doc file to .Net WCF from my Android app.
I am just testing out the onLocationChanged method in Android , I have implemented
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am

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.