Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GPS on emulator doesn't get the geo fix - Android

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

like image 695
Maurizio Pozzobon Avatar asked May 22 '09 08:05

Maurizio Pozzobon


People also ask

How do I enable GPS on my emulator?

When setting up GPS emulator, you need to go to your Settings > About on your Android device. Then tap on the Build number seven times, which activates the developer mode. Now head back to the main settings, where you should see a new option menu called "Developer Options".

Where are Android Emulator files stored?

All applications and files that you have deployed to the Android emulator are stored in a file named userdata-qemu. img located in the C:\Users\<username>\. android\avd\<avd_name>. avd folder.

How do I turn off location on emulator?

Open the settings app in the emulator and uncheck the option with a name like Use GPS satellites . You might have to poke around a bit in the sub options to find it. If you tell us the exact android version, we can tell you where to look exactly. What do you mean by it is enables automatically?


2 Answers

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

like image 79
Maurizio Pozzobon Avatar answered Sep 23 '22 04:09

Maurizio Pozzobon


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

like image 41
Tughi Avatar answered Sep 23 '22 04:09

Tughi