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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:03:25+00:00 2026-05-16T20:03:25+00:00

I need the correct way of getting latitude and longitude in Android programmatically. I

  • 0

I need the correct way of getting latitude and longitude in Android programmatically. I viewed different sites and forums but still I couldn’t get the correct one. The program should support for all the Android versions. I use wifi to get my device connected to net.

  • 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-16T20:03:26+00:00Added an answer on May 16, 2026 at 8:03 pm

    Dont Worry, After scratching my head over few days, I got code working in over a few lines to get longitude and latitude values… I think this will help things go better, Thanks for your suggestions!!!!

    private double[] getGPS() {
    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);  
    List<String> providers = lm.getProviders(true);
    
    /* Loop over the array backwards, and if you get an accurate location, then break out the loop*/
    Location l = null;
    
    for (int i=providers.length();i>=0;i--) {
        l = lm.getLastKnownLocation(providers.get(i));
        if (l != null) break;
    }
    
    double[] gps = new double[2];
    if (l != null) {
        gps[0] = l.getLatitude();
        gps[1] = l.getLongitude();
    }
    return gps;}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is a correct way to update model when view changed. Is it need
I need help to find the correct command, on android, to remove the blue
I need some help understanding the correct way to mix variables with strings like
I am getting an error with this in php. What is the correct way
i need to convert French text to most correct analogue in ASCII. Let me
I need to return an a generic list in the correct order for my
I need to write a regular expression that will be correct for telephone number
I'm trying to correct the usual IE bugs around CSS 2.1 and need a
I need to redirect non-www to www, with correct URL params. A lot of
I need to compute ICMPv6 checksum. I have found correct manual in RFC 2460

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.