problem in showing latitude longitude location in an android app -


The following is the code I use to locate the location and location of the location in my app, but it always shows No location found

I've added permissions to the manifest file

{ LocationManager locManager; SetContentView (R.layout.main); LocManager = (LocationManager) getSystemService (context.LOCATION_SERVICE); locManager.requestLocationUpdates (LocationManager.GPS_PROVIDER, 1000L, 500.0f, locationListener); Location Location = locManager.getLastKnownLocation (LocationManager.GPS_PROVIDER); If (location! = Null) {string param = (string) locManager.getProviders (true) .get (0); Location People = locManager.getLastKnownLocation (Ultimate); Double latitude = location.getLatitude (); Double longitude = location.getLongitude (); }} New zeros with Private Zero Update {location location} {text view myLocationText = (TextView) findViewById (R.id.widget52); String latLongString = ""; If (place! = Null) {double lat = location.getLatitude (); Double LNG = location.getLongitude (); LatLongString = "Lat:" + Latitude + "\ n Long:" + lng; } And {latLongString = "no places found"; } MyLocationText.setText ("Your current state is: \ n" + latLongString); } Private FinalistListenListlister = New LocationalList () {Change Location at Public Zero (Location Location) {updateWithNewLocation (Location); } Provider on Public Zero (Disabled)} Public void onProviderEnabled {String Provider} {} Status Changed on Public Zero (String Provider, Int Position, Bundle Extra) {}};

}

pls help me ...

I've put your code in the Android project and put it on the emulator and it's working fine.

I will change the code to First in check for one last known location, and check that location update then .

  Location Locations = locManager.getLastKnownLocation (LocationManager.GPS_PROVIDER);   

If that location is zero or too old for your needs (timestamp), you can begin requesting location updates. (Currently, you are requesting location update from GPS first, and then decide to get your last available). Due to this, the location manager can stop the GPS inquiries.

In addition to this you must ensure that the following is at:

For the GPS provider, ensure that the following permissions are included in the manifest

  & lt; Usage-permission Android: name = "android.permission.ACCESS_FINE_LOCATION" />   

Make sure GPS is turned on that you have enough GPS coverage.

This GPS icon in your notification bar

Test on a real device

Although test GPS location listeners Works partially through the emulator, the behavior of a real device will always be different.

Debug on the emulator

The original GPS test emulator can be used to keep a breakpoint in your place listener, and some GPS coordinates in your AVD image Use DDMS perspective to send.

Comments