i am new in android create current location and display its city name
i Have No idea About code so give some example to create current location and display also city name thnks in advance
i am new in android create current location and display its city name
i Have No idea About code so give some example to create current location and display also city name thnks in advance
Refrence link http://www.tutorialspoint.com/android/android_location_based_services.htm
Use this code to get location name from latitude and longitude:
for getting latitude and longitude of current location use following steps:
copy and paste code below into it
public class GPSTracker extends Service implements LocationListener {
@Override public void onLocationChanged(Location location) { // TODO Auto-generated method stub
}
@Override public void onProviderDisabled(String provider) { // TODO Auto-generated method stub
}
@Override public void onProviderEnabled(String provider) { // TODO Auto-generated method stub
}
@Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated method stub
}
@Override public IBinder onBind(Intent arg0) { // TODO Auto-generated method stub return null; } }
Now where you want to get latitude and longitude use this code:
GPSTracker mTracker = new GPSTracker(MyActivity.this); double lat = mTracker.getLatitude(); double lng = mTracker.getLongitude();