Hello!
Could you please provide part of code responsible to listen location? Does it show any errors, messages in logCat? Here is an examples how to make simple app with google maps in android:
http://www.codeproject.com/KB/android/GPSLocator.aspx
http://developer.android.com/guide/tutorials/views/hello-mapview.html
http://developer.android.com/resources/tutorials/views/hello-mapview.html
The most important things you should do are:
1. Gain API key to get ability to display map. If you didn't the map just will not show, but app still will be possible to show your location and get coordinates
2. Set permission to manifest:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.INTERNET" />
for wifi and gps.
3. Add google map library:
<application android:icon="@drawable/icon" android:label="@string/app_name">
<uses-library android:name="com.google.android.maps" />
4.To enable locationlistner you simple need to paste this code in your app:
mapView = (MapView) findViewById(R.id.mapView);
// enable Street view by default
mapView.setStreetView(true);
// enable to show Satellite view
// mapView.setSatellite(true);
// enable to show Traffic on map
// mapView.setTraffic(true);
mapView.setBuiltInZoomControls(true);
mapController = mapView.getController();
mapController.setZoom(16);
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationListener = new GPSLocationListener();
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
0,
0,
locationListener);
....
private class GPSLocationListener implements LocationListener
{
@Override
public void onLocationChanged(Location location) {
if (location != null) {
GeoPoint point = new GeoPoint(
(int) (location.getLatitude() * 1E6),
(int) (location.getLongitude() * 1E6));
Toast.makeText(getBaseContext(),
"Latitude: " + location.getLatitude() +
" Longitude: " + location.getLongitude(),
Toast.LENGTH_SHORT).show();
mapController.animateTo(point);
mapController.setZoom(16);
mapView.invalidate();
}
}
...
}
- To get location on emulator you need stable direct(or via proxy if it present) internet connection or you ddms service - android-sdk-windows\tools\ddms.bat -> emulator control -> send gps.
I do this few times it should works. If you still will get problems, send me a piece of responcible code.
also look:
http://codemagician.wordpress.com/2010/05/06/android-google-mapview-tutorial-done-right/
http://www.devx.com/wireless/Article/39145/1954
http://stackoverflow.com/questions/2973290/check-wifi-and-gps-isconnected-or-not-in-android