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
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…