this is crashing my application when i set AutoPanMode and gps on the device is turned off.
locationDisplay.setAutoPanMode( LocationDisplay.AutoPanMode.NAVIGATION );
I first set autopanmode off
locationDisplay.setAutoPanMode( LocationDisplay.AutoPanMode.OFF );
and then allow the user to resume functions and if location services is off the app crashes.
how do i catch this or prevent this (without saying turn location services on).
I tried checkinglocationDisplay.isStarted()
but this passes and the app still crashes.
03-14 15:03:54.934 11143-11143/cmdpoint.org A/art: sart/runtime/check_jni.cc:65] JNI DETECTED ERROR IN APPLICATION: JNI NewLocalRef called with pending exception 'java.lang.NullPointerException' thrown in unknown throw location
03-14 15:03:54.934 11143-11143/cmdpoint.org A/art: sart/runtime/check_jni.cc:65] in call to NewLocalRef
03-14 15:03:54.934 11143-11143/cmdpoint.org A/art: sart/runtime/check_jni.cc:65] from void com.esri.arcgisruntime.internal.jni.CoreLocationDisplay.nativeSetAutoPanMode(long, int)
03-14 15:03:54.934 11143-11143/cmdpoint.org A/art: sart/runtime/check_jni.cc:65] "main" prio=5 tid=1 Runnable
Hi Brian,
Can you give some more details on exactly what's happening in your code? I cant reproduce the crash with the v100.0.0 release currently. I have tried starting the LocationDisplay while location services are turned on, then turning them off, and then setting AutoPanMode; also tried with location services turned off to start with, and a few other workflows, but got no crash. Do you have any listeners (LocationDisplay.DataSourceStatusChangedListener| arcgis-android , LocationDisplay.AutoPanModeChangedListener| arcgis-android , LocationDisplay.LocationChangedListener| arcgis-android ) set up? Does your app already have Location permissions? What version of Android API are you running against?
Thanks
Shelly
I have location services turrn off (for testing).
When i display the map i make these calls.
locationDisplay = mMapView.getLocationDisplay(); locationDisplay.setLocationDataSource( new AndroidLocationDataSource( App.getCurrentActivity(), LocationManager.NETWORK_PROVIDER, 5000L, 1 ) ); locationDisplay.setAutoPanMode( LocationDisplay.AutoPanMode.OFF ); locationDisplay.startAsync(); locationDisplay.addLocationChangedListener( this ); then there is a button that will allow the user to start navigation mode between 2 points. then i turn on auto pan.locationDisplay.setAutoPanMode( LocationDisplay.AutoPanMode.NAVIGATION );this line crashes on me hard.
i think the issue is: if you try and change autopanmode before you ever get a location update it will crash.
Hi Brian - thanks for the extra info - unfortunately I'm still not able to repro your issue. My device has location services turned off, the app has been granted Location permissions (as I'm running Android API 25), the LocationDisplay has been started as per your code, I've not got any calls to the LocationChangedListener yet, and I can set AutoPanMode without getting any crashes - when I do set it I get a location changed call, the Location position is null (expected) at that point. Does your app already have Location permissions? What version of Android API are you running against?
Shelly
I'm running api 22 android 5.1.1.
i think i found the issue. when i set Auto Pan Mode on its calling
onLocationChanged with no actual location data. So when i get the location point and try doing anything with it, it crashes.
it should not call on onlocationchanged if there is no location.