【问题标题】:AndEngine LocationAndEngine位置
【发布时间】:2013-05-01 11:22:02
【问题描述】:

我在看雷达城的例子:

http://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/app/cityradar/CityRadarActivity.java?r=dea4a6fe72f983821ddbc287cfb90a8562f4b433

我已经实现了 ILocationListener 并启用了位置传感器 并且还通过 onResume 方法启用了位置传感器:

@Override
protected synchronized void onResume()
{
    super.onResume();
    System.gc();

    final LocationSensorOptions locationSensorOptions = new LocationSensorOptions();
    locationSensorOptions.setAccuracy(Criteria.ACCURACY_COARSE);
    locationSensorOptions.setMinimumTriggerTime(0);
    locationSensorOptions.setMinimumTriggerDistance(0);
    this.enableLocationSensor(this, locationSensorOptions);
}

然后尝试通过实现的方法获取位置更改的位置

@Override
public void onLocationChanged(Location plocation) {
        this.mUserLocation = plocation;
        curlng = mUserLocation.getLongitude();
        curlat = mUserLocation.getLatitude();


}

但我只得到零,我有点困惑是使用andengine内置的位置传感器还是使用android原生位置传感器?

【问题讨论】:

    标签: java android andengine


    【解决方案1】:

    它使用 Android 位置传感器。

    您应该检查几件事:

    • 您是否在 AndroidManifest.xml 中设置了ACCESS_FINE_LOCATIONACCESS_COARSE_LOCATION 权限?
    • 检查您的设备是否开启了 GPS。即使已开启,也可能需要一段时间才能锁定。

    除非您发布 Logcat 输出,否则无法给出准确的答案。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多