我正在为安卓操作系统开发一个应用程序,我才刚刚开始,但我无法让模拟器上的 GPS 工作。我在互联网上读到您需要向模拟器发送地理修复以启用 gps locationProvider。我都在使用 DDMS 和 telnet 来尝试发送它,但是 logcat 从来没有告诉我它收到了一个新的修复程序,而且我的道歉仍然认为 gps 被禁用
这是我的代码
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");
}
}
我读过 DDMS 可能无法在非英语操作系统上正常工作,但 telnet 应该可以工作!
更新:在设置中启用了gps