private final NMapLocationManager.OnLocationChangeListener onMyLocationChangeListener = new NMapLocationManager.OnLocationChangeListener() {
@Override
public boolean onLocationChanged(NMapLocationManager locationManager, NGeoPoint myLocation) {
if (mMapController != null) {
mMapController.animateTo(myLocation);
}
Log.d("myLog", "myLocation lat " + myLocation.getLatitude());
Log.d("myLog", "myLocation lng " + myLocation.getLongitude());
findPlacemarkAtLocation(myLocation.getLongitude(), myLocation.getLatitude());
//Translate latitudes to addresses
return true;
}
Currently, Naver map is implemented to search the current location through markers through API. However, if you press the Back button on the map screen, the application stops immediately.
Below is the error screen.
FATAL EXCEPTION: main Process: com.kim.bisos, PID: 19493 java.lang.IllegalStateException: findPlacemarkAtLocation() could not be invoked prior to setMapDataProviderListener(). at com.nhn.android.maps.NMapContext.findPlacemarkAtLocation(NMapContext.java) at com.nhn.android.maps.NMapActivity.findPlacemarkAtLocation(NMapActivity.java) at `
`com.kim.bisos.NaverMyLocation$2.onLocationChanged(NaverMyLocation.java:180)
com.nhn.android.maps.NMapLocationManager.onLocationChanged(NMapLocationManager.java) at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:281) at android.location.LocationManager$ListenerTransport.access$000(LocationManager.java:210) at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:226) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5951) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
'''
I think the part marked in dark color means an error. I'd really appreciate your help.
android
The error content must first call setMapProviderListener(OnDataProviderListener)
before calling the findPlacemarkAtLocation()
function.Exhibition caused by breaking the restriction.
If it only occurs when it goes back to normal in a normal case, it is assumed that the onLocationChanged()
callback was called after the MapDataProviderListener was internally terminated at the end of the activity's lifecycle.
One of the solutions is to set setOnLocationChangeListener(null)
at the time of going back so that onLocationChanged()
callback is no longer invoked.
© 2024 OneMinuteCode. All rights reserved.