0

我正在尝试使用 android 模拟器进行 Eclipse。我已经使用 telnet 和模拟器 ddms 设置了我的模拟器地理点。

出于某种原因,当我试图从模拟器中获取我的位置时,它总是返回 0,0 给我。我想也许我不是从正确的位置提供的。应该在模拟器中使用哪些提供程序?

这是我的代码:

locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        location = locationManager
                .getLastKnownLocation(LocationManager.GPS_PROVIDER);
        if (location == null) {
            location = locationManager
                    .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

            if (location == null) {
                Toast.makeText(
                        this,
                        "Couldn't get your location, map will be unavailable",
                        8000).show();
            }
            else
            {
                app.setLatitude((int) (location.getLatitude() * 1E6));
                app.setLongitude((int) (location.getLongitude() * 1E6));
            }
        } else {
            app.setLatitude((int) (location.getLatitude() * 1E6));
            app.setLongitude((int) (location.getLongitude() * 1E6));
        }
4

1 回答 1

0

使用这些 telnet 命令在模拟器中设置 GPS 定位和位置:

http://developer.android.com/guide/developing/devices/emulator.html#geo

geo <fix|nmea>
于 2012-05-30T16:00:11.103 回答