我正在应用程序中使用Mapbox导航,例如Uber,我开始旅行并开始导航到某个点。一切正常,但在导航的某个点上我的应用程序冻结了,并且我收到警告,我的应用程序没有响应。
这是我的依赖
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.40.0'
我的班级收到LocationEngineResult
``
公共类LocationCallback实现LocationEngineCallback {
private final WeakReference<NavigationFragment> activityWeakReference;
private Location prelocation;
public LocationCallback(NavigationFragment navigationFragment) {
this.activityWeakReference = new WeakReference<NavigationFragment>(navigationFragment);
}
@Override
public void onSuccess(LocationEngineResult result) {
Log.e("Tag", "NavigationFragment locationEngineResult");
NavigationFragment context = activityWeakReference.get();
if (context != null) {
Location location = result.getLastLocation();
Log.d("Tag", "Result location: " + location.toString());
if (location == null) {
return;
}
if(prelocation == null){
context.checkFirstUpdate(location);
context.onLocationChanged(location);
prelocation = location;
}
else{
if(AppHelper.distance(prelocation.getLatitude(), prelocation.getLongitude(), location.getLatitude(), location.getLongitude()) > 0){
context.checkFirstUpdate(location);
context.onLocationChanged(location);
prelocation = location;
}
}
}
}
@Override
public void onFailure(@NonNull Exception exception) {
Log.d("Tag", "On failure exception" + exception.getMessage());
Timber.e(exception);
}
} ``
我已经处理了几天,并且我假设我的LocationEngine回调停止获取我的位置结果。
这是我的Logcat:
PID: 18359
Reason: Broadcast of Intent { act=com.mapbox.android.telemetry.location.locationupdatespendingintent.action.LOCATION_UPDATED flg=0x10 launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } (has extras) }
Load: 2.85 / 4.21 / 4.5
CPU usage from 901ms to -4460ms ago (2019-06-14 17:13:07.541 to 2019-06-14 17:13:12.902):
24% 3658/system_server: 13% user + 10% kernel / faults: 7699 minor 6681 major
请提出任何建议可能会有所帮助。我可以提供更多代码。谢谢!