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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:44:37+00:00 2026-05-25T03:44:37+00:00

I have a problem with my Location Listener in a MapView Application. Especially there

  • 0

I have a problem with my Location Listener in a MapView Application.
Especially there is a Problem with the time, my actual Position will be painted on a Map.

I attached two listeners to my MapView. The first one waits for a signal from the Network and the second one from the GPS. At the beginning of the Listener Implementation I get the Last Known Location to reduce the Time while other providers search a position.

My LocationListner in the MapView is called as followed:

public void locationManager(){

    mLocationUpdateHandlerGPS       = new LocationUpdateHandler();
    mLocationUpdateHandlerNetwork   = new LocationUpdateHandler();

    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

    //-------Check if Network is available-----
    mLocationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, mLocationUpdateHandlerNetwork);

    //-------Check if GPS is available---------
    mLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 500, 1, mLocationUpdateHandlerGPS);


}

The LocationUpdateHandler.class where i implemented the Listener looks like this:

public class LocationUpdateHandler implements LocationListener {

    @Override
    public void onLocationChanged(Location location) {

        location = mLocationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

        int lat = (int) (location.getLatitude() * 1E6);
        int lng = (int) (location.getLongitude() * 1E6);

        //Log Actual Position
        Log.v(TAG, "Actual Postion // Get Latitude: " + lat);           
        Log.v(TAG, "Actual Postion // Get Longitude: " + lng);

        mMyLocationOverlay.enableMyLocation();
        Log.v(TAG, "Enable Location returns: "+mMyLocationOverlay.enableMyLocation());

        mMyLocationOverlay.runOnFirstFix(new Runnable() {
            @Override
            public void run() {
                mMapView.getController().animateTo(
                        mMyLocationOverlay.getMyLocation());
            }
        });
    }

}

After the Map starts i check the Log Output from the DDMS and can see that the Location is get in Time.

08-29 14:50:16.136: VERBOSE/GeoTagMapActivity(7300): Running Activity GeoTagMapActivity
08-29 14:50:20.691: VERBOSE/GeoTagMapActivity(7300): Enable Location returns: true
08-29 14:50:20.691: VERBOSE/GeoTagMapActivity(7300): Actual Postion // Get Latitude: *******
08-29 14:50:20.691: VERBOSE/GeoTagMapActivity(7300): Actual Postion // Get Longitude: *******

Nevertheless i takes another 2 – 5 minutes until the Position will drawn on the Map.

I have no idea where’s the Problem.
Thanks for your help!

  • 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-25T03:44:37+00:00Added an answer on May 25, 2026 at 3:44 am

    MyLocationOverlay is a helper class of Google Maps for Android. It does it’s own location acquiring, more specifically it uses GPS to do it.

    Since you call runOnFirstFix(runnable) it waits to get a GPS fix before executing your code. This can sometimes (especially indoor) take minutes. Hence the delay. It’s also entirely possible to acquire network-based location, but not GPS position (especially indoors), so in this case your code would never be executed (except if MyLocationOverlay falls back to network provider after timeout – this isn’t explained anywhere).

    The position that you see in the logs are positions that you acquire via network location provider (wifi and cell network locations).

    Just remove runOnFirstFix() as @user370305 suggested in comments.

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

Sidebar

Related Questions

I have problem with my Android application. I need an application that will send
I have an app that will get the users gps location. The problem is
I have a strange problem that is only happening in a single location. I
I have problem with fancybox. I want to write a function that will run
I have problem while setting the Jlabel location. I set the content pane to
I have problem occuring in my application.. Using XML file i am getting geopoints
I still have problem with fetching first location on android. I am using Criteria
Hello there i'm having a problem here i have an add and edit form
Now I create a small PHP Application, here I have problem for using file
I have a problem in getting the user's location (my location). My code is

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.