hi...
I have been trying to get my current location but fail to get it.
I am using wifi. I tried
geo fix -77.036519 38.896143. but still its not working.
Here is my code:
I think its the problem with my emulator but not sure. Can anybody please help me to fix this thing..!!
I have been trying to get my current location but fail to get it.
I am using wifi. I tried
geo fix -77.036519 38.896143. but still its not working.
Here is my code:
Code:
public class whereAmI extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
LocationManager locationManager;
String context = Context.LOCATION_SERVICE;
locationManager = (LocationManager)getSystemService(context);
String provider = LocationManager.GPS_PROVIDER;
Location location = locationManager.getLastKnownLocation(provider);
updateWithNewLocation(location);
}
private void updateWithNewLocation(Location location) {
String latLongString;
TextView myLocationText;
myLocationText = (TextView)findViewById(R.id.myLocationText);
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
latLongString = "Lat:" + lat + "\nLong:" + lng;
} else {
latLongString = "No location found";
}
myLocationText.setText("Your Current Position is:\n" +
latLongString);
}
}