android位置模拟器

时间:2012-05-30 15:44:24

标签: android android-emulator location

我正在尝试使用Android模拟器进行日食。 我使用telnet和emulator 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));
        }

1 个答案:

答案 0 :(得分:0)

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

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

geo <fix|nmea>
相关问题