6

我正在为安卓操作系统开发一个应用程序,我才刚刚开始,但我无法让模拟器上的 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

4

4 回答 4

5

事实证明,因为我是为 Android 1.5(而不是 Google API 1.5)开发的,所以地图(看起来像其他功能)被禁用了。一旦我更改了目标平台,我的错误就消失了。

顺便说一句,谢谢大家

于 2009-05-25T11:56:47.387 回答
1

要测试 geofix 是否正常工作,您可以使用带有“我的位置”的 Google 地图应用

于 2009-05-25T08:00:20.017 回答
1

确保在设置中启用了 gps。如果问题仍然存在,您只需转到主菜单中名为 Navigation 的应用程序,运行它并退出。现在试试你的应用程序。您可以通过选择特定设备在 DDMS 透视图中启用模拟器控制下的位置控制。如果不选择设备,它将无法工作

于 2011-09-27T13:25:48.780 回答
0

我想已经修复了,但是在代码中你应该使用 LocationManager 服务返回的字符串作为提供者,而不是你输入的“gps” l.getLastKnownLocation("gps")

于 2010-04-25T15:51:18.003 回答