6

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

luvieere
  • 37,065
  • 18
  • 127
  • 179
Maurizio Pozzobon
  • 3,044
  • 7
  • 34
  • 44

4 Answers4

5

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

Maurizio Pozzobon
  • 3,044
  • 7
  • 34
  • 44
  • 1
    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 Jul 02 '10 at 00:47
1

Make sure that the gps in enabled in the settings. If still the problem persists, you just go to the application named Navigation in the main menu, run it and exit. Now try your application. You can enable location controls under emulator control in DDMS perspective by selecting a particular device. without selecting a device it will not work

Jiju Induchoodan
  • 4,236
  • 1
  • 22
  • 24
1

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

Tughi
  • 1,093
  • 1
  • 11
  • 20
0

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
  • 700
  • 1
  • 5
  • 17