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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:54:08+00:00 2026-05-27T23:54:08+00:00

I have implemented sample application for get the current location latitude longitude.If i lunch

  • 0

I have implemented sample application for get the current location latitude longitude.If i lunch my application in emulator and i am sending latitude and longitude from Emulator Controls at eclipse then i am getting current location latitude and longitude which from emulator controls.If i lunch the same application in real device then i am not able to get current location latitude and longitude

I have implemented code for get the current location latitude and longitude as follows:

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

  LocationListener mlocListener = new MyLocationListener();
  mlocManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 11, 11, mlocListener);


   public class MyLocationListener implements LocationListener
{

  @Override
  public void onLocationChanged(Location loc)
  {

    loc.getLatitude();
    loc.getLongitude();

   Log.v("11111","Latitude :"+loc.getLatitude());
   Log.v("22222","Longitude :"+ loc.getLongitude());

    }

}

From the above code i am not getting current location latitude and longitude in real android device.

How can i get current location latitude and longitude of real device?

please any body 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-27T23:54:09+00:00Added an answer on May 27, 2026 at 11:54 pm

    prasad try this code ..by using this i am successfully getting lat long

            private Location location = null;
            private LocationManager locationManager = null;
        locationManager = (LocationManager) context.getSystemService                              (Context.LOCATION_SERVICE);
    
        Criteria locationCritera = new Criteria();
        locationCritera.setAccuracy(Criteria.ACCURACY_FINE);
        locationCritera.setAltitudeRequired(false);
        locationCritera.setBearingRequired(false);
        locationCritera.setCostAllowed(true);
        locationCritera.setPowerRequirement(Criteria.NO_REQUIREMENT);
    
        String providerName = locationManager.getBestProvider(locationCritera,
                true);
        location = locationManager.getLastKnownLocation(providerName);
        locationListener = new MyLocationListener();
    
        locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0,
                0, locationListener);
    
        currentLocation = context.getSharedPreferences(PREFS_NAME, 0);
        editor = currentLocation.edit();
    }
    public String getCurrentLatitude() {
        try {
            if (!currentLocation.getString("currentLatitude", "")
                    .equalsIgnoreCase(""))
                return currentLocation.getString("currentLatitude", "");
            else if (location.getLatitude() != 0.0)
                return Double.toString(location.getLatitude());
            else
                return "0.0";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "0.0";
    }
    
    public String getCurrentLongitude() {
        try {
    
    
            if (!currentLocation.getString("currentLongitude", "")
                    .equalsIgnoreCase(""))
                return currentLocation.getString("currentLongitude", "");
            else if (location.getLongitude() != 0.0)
                return Double.toString(location.getLongitude());
            else
                return "0.0";
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "0.0";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In our desktop application, we have implemented a simple search engine using an inverted
Very simple Qt GUI application: On the scene I have multiple circles implemented as
i am porting my application from windows forms to WPF. I have found that
I have implemented sample applicatioon with ListActivty.I have used CustomAdapter and i am getting
I am using eclipse 3.6. I created one sample plugin application. It is neither
I have implemented simple com.sun.net.httpserver.HttpServer application using one of examples in the internet. Server
I have just implemented my first Restlet application (finally :]) and now I'm onto
I have created android avd emulator with api level 13 and i have implemented
I implemented Licensing Service in my application using the sample given with licensing module.
I have implemented a simple jqGrid in my ASP.NET MVC 3 application. It shows

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.