Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AndEngine Location

I'm looking at the example of radar city example :

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

and i have implemented the ILocationListener and have enabled the location sensor and have also enabled the location sensor through the onResume method:

@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);
}

and then tried to get location on the location changed through the implemented method

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


}

but i am only getting zeros and i am little bit confused on whether or not use the location sensor built in andengine or use the android native location sensor?

like image 576
angrymuffins Avatar asked Jun 07 '26 05:06

angrymuffins


1 Answers

It uses the Android Location Sensor.

There are few things that you should check:

  • Have you set the ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION permissions in your AndroidManifest.xml?
  • Check whether GPS is on in your device. Even if it's on, it might take a while to lock on.

It won't be possible to give an exact answer unless you post your Logcat output.

like image 173
ramdesh Avatar answered Jun 08 '26 18:06

ramdesh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!