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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:16:33+00:00 2026-06-01T01:16:33+00:00

I am currently try to retrieve a latitude and longitude value from a location.

  • 0

I am currently try to retrieve a latitude and longitude value from a location. When i convert the location to integer values using the following code:

    LocationManager locMan;
    Location location;
    String towers;
    private static double lat;
    private static double lon;

    locMan = (LocationManager) getSystemService(Context.LOCATION_SERVICE);          
    Criteria crit = new Criteria();

    towers = locMan.getBestProvider(crit, false);
    location = locMan.getLastKnownLocation(towers);                 

        if (location != null)
        {                   

            lat = (int) (location.getLatitude() * 1E6);
            lon = (int) (location.getLongitude() * 1E6);
            GeoPoint ourLocation = new GeoPoint(lati, longi);
            OverlayItem overlayItem = new OverlayItem(ourLocation, "1st String", "2nd String");
            CustomPinpoint custom = new CustomPinpoint(d, MainMap.this);
            custom.insertPinpoint(overlayItem);
            overlayList.add(custom);
            overlayList.clear();    

            lat = (double) lat;             
            lon = (double) lon; 

            System.out.println("Lat is  " + lat);
            System.out.println("Longi is  " + lon);
        }
        else
        {
            System.out.println("Location is null! " + towers);
            Toast.makeText(MainMap.this, "Couldn't get provider", Toast.LENGTH_SHORT).show();                   
        }

it comes back in the format of 0.000000

lat is 5.494394
long is -7.724457

how can i get it back in the format 00.000000

I have tried DecimalFormat, Math.Round and various other solutions i found on Stack Overflow but still get the same result. Please 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-06-01T01:16:35+00:00Added an answer on June 1, 2026 at 1:16 am

    Have you tried this:

    DecimalFormat sf = new DecimalFormat("00.000000");
    String s = sf.format(5.494394);
    System.out.println(s); //prints 05.494394
    

    EDIT

    Based on your new question, why don’t you do this:

    double latitude = location.getLatitude();
    double longitude = location.getLongitude();
    GeoPoint ourLocation = new GeoPoint((int) (latitude * 1E6), (int) (longitude * 1E6));
    //....
    System.out.println("Lat is  " + latitude);
    System.out.println("Longi is  " + longitude);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently downloading an HTML page, using the following code: Try Dim req As
I am currently using code similar to this: try { // IE ONLY var
I am currently using PIL. from PIL import Image try: im = Image.open(filename) #
I'm currently using the following (old) code to log into a site... public function
I am currently using two catch blocks after a try block. The first catches
I want to get the value of current location. I use this code but
I have code to retrieve data from a database into a form but it
I am currently using phonegap and trying to display results from a sqlite table
I'm using the following code to build a list of email addresses on the
I currently try to use Reachability in iOS 5.1 on iPad. There is a

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.