Android Emulator does not receive Location Mock Data

Common bugs/problems with the Android SDK the Emulator and the ADT-Plugin.

Android Emulator does not receive Location Mock Data

Postby discostu » Mon Jan 12, 2009 10:39 am

Hi,

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:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="UTF-8"?>
  3.  
  4. <kml xmlns="http://earth.google.com/kml/2.2">
  5.  
  6. <Document>
  7.  
  8.   <name>GE2ADT</name>
  9.  
  10.      <Placemark>
  11.  
  12.                 <name>0</name>
  13.  
  14.                 <description>GE2ADT Route</description>
  15.  
  16.                 <Point><coordinates>14.52178600857711,48.3725047834725,0</coordinates></Point>
  17.  
  18.         </Placemark>
  19.  
  20.         <Placemark>
  21.  
  22.                 <name>1</name>
  23.  
  24.                 <description>GE2ADT Route</description>
  25.  
  26.                 <Point><coordinates>14.52130990553162,48.37223586242269,0</coordinates></Point>
  27.  
  28.         </Placemark>
  29.  
  30.      <Placemark>
  31.  
  32.                 <name>2</name>
  33.  
  34.                 <description>GE2ADT Route</description>
  35.  
  36.                 <Point><coordinates>14.52084041595454,48.37202500476206,0</coordinates></Point>
  37.  
  38.         </Placemark>
  39.  
  40.      ...
  41.  
  42. </Document>
  43.  
  44.  
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:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. List<String> providers = locationManager.getProviders(true);
  2.  
  3. for(String provider : providers) {
  4.         locationManager.requestLocationUpdates(provider, 1000, 0, new LocationListener() {
  5.                 public void onLocationChanged(Location location) {}
  6.                 public void onProviderDisabled(String provider) {}
  7.                 public void onProviderEnabled(String provider) {}
  8.                 public void onStatusChanged(String provider, int status, Bundle extras) {}
  9.         });
  10.        
  11.         sb.append("\n").append(provider).append(": ");
  12.        
  13.         Location location = locationManager.getLastKnownLocation(provider);
  14.         if(location != null) {
  15.                 double lat = location.getLatitude();
  16.                 double lng = location.getLongitude();
  17.                
  18.                 sb.append(lat).append(", ").append(lng);
  19.         } else {
  20.                 sb.append("No Location");
  21.         }
  22. }
  23.  
Parsed in 0.032 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.
discostu
Freshman
Freshman
 
Posts: 3
Joined: Mon Jan 12, 2009 10:23 am

Top

Postby discostu » Sat Jan 17, 2009 9:55 am

Solved: Changed number-format in Windows XP to "English (United States)"
discostu
Freshman
Freshman
 
Posts: 3
Joined: Mon Jan 12, 2009 10:23 am

Postby frasurf » Mon Jan 26, 2009 5:51 pm

discostu wrote:Solved: Changed number-format in Windows XP to "English (United States)"


Thank you very much!!!!
I spent half of my day trying to get which could be the problem....

So I suppose there is a bug in the DDMS plugin....
frasurf
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Jan 26, 2009 5:38 pm

Postby discostu » Mon Jan 26, 2009 5:58 pm

I'm glad i could help :).

Yes, it is a already reported bug (Issue 915).
discostu
Freshman
Freshman
 
Posts: 3
Joined: Mon Jan 12, 2009 10:23 am

Top

Return to SDK/ADT/Emulator Problems

Who is online

Users browsing this forum: No registered users and 4 guests