views:

3789

answers:

5

Hi I'm developing an application for the android OS, I'm just starting, but I can't get the GPS on the emulator to work. I've read on the internet that you need to send a geo fix to the emulator in order to enable the gps locationProvider. I'm both using the DDMS and telnet to try to send it, but logcat never tells me the it recived a new fix, and my apolication still sees the gps as disabled

here's my code

package eu.mauriziopz.gps;

import java.util.Iterator;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.location.LocationManager;
import android.os.Bundle;
import android.util.Log;

public class ggps extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        LocationManager l =(LocationManager) getSystemService(Context.LOCATION_SERVICE);
        List<String> li = l.getAllProviders();
        for (Iterator<String> iterator = li.iterator(); iterator.hasNext();) {
      String string =  iterator.next();
      Log.d("gps", string);
     }
        if (l.getLastKnownLocation("gps")==null)
            Log.d("gps", "null");   
    }
}

I've read that the DDMS may not work properly on a non english OS, but telnet should work!

update: the gps is enabled in the settings

A: 

Is the GPS provider enabled in the emulator?

Tughi
if you mean in the settings, yes it is
MaurizioPz
+1  A: 

To test if the geofix is working you could use the Google Maps app with "My Location"

Tughi
+2  A: 

Turns out, that since I was developing for Android 1.5 (and not Google API 1.5) the map (and looks like other features) were disabled. As soon as I changed the target platform, my error disappeared.

btw thanks all

MaurizioPz
Thanks! To all: You can change the Build Target for your project any time in Eclipse: Right-click the project in Package Explorer, select Properties > Android and then check 'Google API' for Project Target. -- Developers working with non-English culture settings might notice that pressing the Send button in Location Controls does not send a new location to the Android emulator. It's fixed with the upcoming release 7 of the SDK tools; for a quick fix you can change your locale to 'en'. (See http://code.google.com/p/android/issues/detail?id=915 for details.)
Patrick de Kleijn
A: 

It worked for me when I turned on the GPS settings in emulator. Thanks Tughi.

adityad
A: 

I supose is fixed yet, but in the code you should use as provider a string returned by the LocationManager service, instead of "gps" as you put in l.getLastKnownLocation("gps").

CHiRo79