【问题标题】:Dynamic geo Location update in android emulator?android模拟器中的动态地理位置更新?
【发布时间】:2012-11-02 12:04:38
【问题描述】:

我正在使用Location Manager 获取当前的经度和纬度,但在模拟器中出现错误。如何在模拟器上获取位置?

这是我的代码:

lm = (LocationManager) context
    .getSystemService(Context.LOCATION_SERVICE);
    android.location.Location currentLocation = lm
    .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
    if (currentLocation == null)
        currentLocation = lm
        .getLastKnownLocation(LocationManager.GPS_PROVIDER);

    if (currentLocation != null) {
        currentLongitude = currentLocation.getLongitude();
        currentLatitude = currentLocation.getLatitude();

        // Get last location of driver
        lastLongitude = Double.valueOf(app.GetLongitude(context));
        lastLatitude = Double.valueOf(app.GetLatitude(context));
        distance = CommonFunctions.GetDistance(currentLongitude,
                currentLatitude, lastLongitude, lastLatitude);
}

【问题讨论】:

  • 你遇到了哪个错误??发布 logcat..

标签: android android-emulator


【解决方案1】:

您将在 Eclipse 的 DDMS 透视图中找到此窗口。这样您就可以使用各种位置值测试您的应用程序。

按照以下步骤设置模拟值:

转到eclipse DDMS透视图,Via

Windows>Open Perspective > other > DDMS(可以输入过滤列表)

找到模拟器控制选项卡

然后在位置控制框内

您可以向模拟器发送 lat、long 以模拟 gps 变化。

如果找不到 Emulator Control,只需通过以下方式打开它:

Windows > show view > other > Emulator Control (你可以输入过滤列表)

【讨论】:

    【解决方案2】:

    在 Eclipse 中打开您的 Emulator 控件并在 Location 控件中设置 lat,long

    【讨论】:

      【解决方案3】:

      对于一个非常解释的答案,你可以在这里查看:How to emulate GPS location in the Android Emulator?

      在这篇文章中,它解释了如何处理问题!

      希望这会有所帮助!

      【讨论】:

        【解决方案4】:

        首先你必须打开模拟器控制视图(Window->showView-> other->emulator control)。 然后,当您的应用程序启动时,在 emulator control 中的位置控制处, 设置位置并点击发送按钮

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2017-07-13
          • 1970-01-01
          • 2012-01-26
          • 2022-12-18
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多