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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:59:02+00:00 2026-05-27T09:59:02+00:00

I created a program that displays a mapView, with the location of the phone,

  • 0

I created a program that displays a mapView, with the location of the phone, and the ability to send this location (latitude, longitude) through email. (to add some places to a database).

I’m using the LocationManager class and getLatitude / getLongitude methods to get the phone’s location. My code looks like this:

double MyLongitude  = 0;
double MyLatitude   = 0;
Location location   = null;

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

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 35000, 10, new ShowLocation()); 

location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);

MyLatitude  = location.getLatitude();
MyLongitude = location.getLongitude();

When test my application on the emulator, everything is OK: mapView displays the location I fixed (using telnet and geo fix command), and I can send the location through email. I get the same result on the phone of a friend; everything seems to work OK.

The problem is on my phone. I can display my location on the mapView (the little blue circle), but when I try to send my location through email, the Latitude and Longitude were both set to 0.

Here is the code to display my location on the mapView:

MyLocationOverlay myLocation = new MyLocationOverlay(this, mapView);
myLocation.enableMyLocation();

I don’t understand why my location appears to work when displayed, but I can’t get the correct latitude and longitude, while it seems to work on emulator and my friend’s phone.

Is this due to missing code or something like that? Is this a problem with my phone? I checked the permissions, and I already have the needed ones:

android.permission.ACCESS_FINE_LOCATION
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_MOCK_LOCATION

I also tried to test with LocationManager.NETWORK_PROVIDER instead of LocationManager.GPS_PROVIDER, but got the same result.

  • 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-27T09:59:03+00:00Added an answer on May 27, 2026 at 9:59 am

    You can override onLoationChanged(Location l) on your MyLocationOverlay, which will get called whenever the overlay gets a new location to draw your position, instead of requesting location updates and getLastKnownLocation.

    I am guessing that getLastKnownLocation is returning 0, 0 because there hasn’t been a location fix yet.

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

Sidebar

Related Questions

I bought this program that created a pretty nice imageuploader flash script however I
I created a program that more or less holds an array of strings as
I've created a program that creates and populates a custom document property in an
I created a server program that will be started as root. After it is
I'm basically trying to play with recursions and created a small program that finds
I created a program in C++2011 that actually uses features of C++2011: mutex ,
I am contemplating writing a program that will move some newly created dirs to
I have created a non-form c# program that uses the NotifyIcon class. The text
I created one GWT webapplication project.Inthat i want to create servlet program,but in that
I created a JApplet using Netbeans 6.5.1 that accesses a database. When the program

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.