I am trying to use location data in my android application and since I don't have a hardware device I try to feed the emulator with some mock-data by using the location control from DDMS. My kml-file has the following format:
Using xml Syntax Highlighting
- <?xml version="1.0" encoding="UTF-8"?>
- <kml xmlns="http://earth.google.com/kml/2.2">
- <Document>
- <name>GE2ADT</name>
- <Placemark>
- <name>0</name>
- <description>GE2ADT Route</description>
- <Point><coordinates>14.52178600857711,48.3725047834725,0</coordinates></Point>
- </Placemark>
- <Placemark>
- <name>1</name>
- <description>GE2ADT Route</description>
- <Point><coordinates>14.52130990553162,48.37223586242269,0</coordinates></Point>
- </Placemark>
- <Placemark>
- <name>2</name>
- <description>GE2ADT Route</description>
- <Point><coordinates>14.52084041595454,48.37202500476206,0</coordinates></Point>
- </Placemark>
- ...
- </Document>
Parsed in 0.004 seconds, using GeSHi 1.0.8.4
(I have already tried various kml-formats and also gpx files. This one is created manually by Google Earth and then converted by http://ge2adt.appspot.com/)
I start the DDMS first and then the emulator. Then I load the kml-file and after that I start the maps application and try to go to "My Location" (while the DDMS location control is still in playback mode). However, the emulator is not able to find any location, but instead throws a exception (related to the network provider):
Logcat output:
- Code: Select all
D/LocationManager( 3192): removeUpdates: listener = com.google.android.maps.TappableMyLocationOverlay@434a7c00
D/LocationManagerService( 55): _removeUpdates: listener = android.os.BinderProxy@433732e8
D/GpsLocationProvider( 55): setMinTime 1000
D/LocationManagerService( 55): _requestLocationUpdates: listener = android.os.BinderProxy@434ba828
D/GpsLocationProvider( 55): setMinTime 0
I/Maps.MyLocationOverlay( 3192): Request updates from gps
E/LocationManagerService( 55): isProviderEnabled got exception:
E/LocationManagerService( 55): java.lang.IllegalArgumentException: provider=network
E/LocationManagerService( 55): at com.android.server.LocationManagerService._isProviderEnabled (LocationManagerService.java:1210)
E/LocationManagerService( 55): at com.android.server.LocationManagerService.isProviderEnabled (LocationManagerService.java:1196)
E/LocationManagerService( 55): at android.location.ILocationManager $Stub.onTransact(ILocationManager.java:211)
E/LocationManagerService( 55): at android.os.Binder.execTransact (Binder.java:276)
E/LocationManagerService( 55): at dalvik.system.NativeStart.run (Native Method)
I/NotificationService( 55): enqueueToast pkg=com.google.android.apps.maps callback=android.app.ITransientNotification$Stub$Proxy@43532348 duration=0
The same thing happens when I use my own application:
Using java Syntax Highlighting
- List<String> providers = locationManager.getProviders(true);
- for(String provider : providers) {
- locationManager.requestLocationUpdates(provider, 1000, 0, new LocationListener() {
- public void onLocationChanged(Location location) {}
- public void onProviderDisabled(String provider) {}
- public void onProviderEnabled(String provider) {}
- public void onStatusChanged(String provider, int status, Bundle extras) {}
- });
- sb.append("\n").append(provider).append(": ");
- Location location = locationManager.getLastKnownLocation(provider);
- if(location != null) {
- double lat = location.getLatitude();
- double lng = location.getLongitude();
- sb.append(lat).append(", ").append(lng);
- } else {
- sb.append("No Location");
- }
- }
Parsed in 0.033 seconds, using GeSHi 1.0.8.4
The code above gives me exactly one provider ("gps"), but getLastKnownLocation returns null.
Some further information:
In the settings menu I have disabled "Use wireless networks" and enabled "Enable GPS satellites".
On the filesystem there is no "network"- but a "gps"-folder in /data/location.
- Code: Select all
+ data
[...]
+ location
+ gps
- location
- nmea
- properties
[...]
I have absolutely no clue why it does not work and I don't know how to debug that issue.
What could be a reason for that and how could i find out?
I am using Windows XP, "android-sdk-windows-1.0_r2" and Eclipse 3.4.
Kind regards,
Chris.

.
