【问题标题】:How to simulate speed on Android emulator?如何在 Android 模拟器上模拟速度?
【发布时间】:2011-02-23 00:27:45
【问题描述】:

有没有办法在安卓模拟器上模拟速度?

[编辑] 这样做的目的是为了测试getSpeed()方法

示例: 我想设置设备以每小时 20 英里的速度行驶。

【问题讨论】:

  • 你能指定“模拟速度”吗?
  • 我所说的速度是设备的运动速率。

标签: android android-emulator


【解决方案1】:

Location 对象有一个方法来设置设备的速度:

//the instance
Location location;

//retrieves the speed of the device
location.getSpeed()

// set the speed of the device of course for testing purporses, remember to
// remove this when deploying your appplication
location.setSpeed((float) 20.0)

如果您想模拟一段时间内的速度变化,您可以设置一个计时器并在该时间段内降低或提高速度,例如:

int secondsDelayed = 5;
new Handler().postDelayed(new Runnable() {
    public void run() {
        location.setSpeed((float) 50.0);
    }
}, secondsDelayed * 1000);

这将在 5 秒内将速度提高到 50 km/p

【讨论】:

    【解决方案2】:

    我的高配置电脑 3i 4GB 也遇到了同样的问题,但是模拟器运行速度很慢 我找到了一些对我有用的东西,希望它对其他人有用,我很乐意在这里分享它

    我刚刚将Device ram size 添加到我现有的AVD 并设置size to 1000MB(因为我有足够的空间来分配4GB) 不,我的AVD 的速度是最终希望它可以帮助你。

    【讨论】:

      【解决方案3】:

      是的,您可以这样做。如果您使用 Eclipse 开发您的应用程序,您必须转到 DDMS 透视图。在那里你应该找到一个名为 Emulator control 的窗口。在此窗口中,您可以将新的地理位置(GPS 坐标)发送到您的模拟器或设备。当您想提高速度时,最好使用 GPX 或 KML 文件。在此文件中,您可以定义 GPS 坐标,然后逐步读取这些坐标。通过适当地选择这个坐标,您可以模拟一个恒定的速度。

      【讨论】:

      • 我正要这么说。这样做,科里
      • 模拟器速度不会影响 location.getSpeed()。所以这不是正确的答案。
      猜你喜欢
      • 2014-12-10
      • 1970-01-01
      • 2015-06-04
      • 1970-01-01
      • 2013-01-10
      • 2012-05-15
      • 1970-01-01
      • 2011-04-24
      • 2018-02-13
      相关资源
      最近更新 更多