From 471703e5336033d71f574ed8132f0b6c4e9ce949 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 30 May 2017 12:26:10 +0300 Subject: [PATCH] Fix crash at OsmandAidlApi --- OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java index 37b42efe43..5293ff233f 100644 --- a/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java +++ b/OsmAnd/src/net/osmand/aidl/OsmandAidlApi.java @@ -88,25 +88,55 @@ public class OsmandAidlApi { public void onDestroyMapActivity(final MapActivity mapActivity) { if (refreshMapReceiver != null) { - mapActivity.unregisterReceiver(refreshMapReceiver); + try { + mapActivity.unregisterReceiver(refreshMapReceiver); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + refreshMapReceiver = null; } if (setMapLocationReceiver != null) { - mapActivity.unregisterReceiver(setMapLocationReceiver); + try { + mapActivity.unregisterReceiver(setMapLocationReceiver); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + setMapLocationReceiver = null; } if (addMapWidgetReceiver != null) { - mapActivity.unregisterReceiver(addMapWidgetReceiver); + try { + mapActivity.unregisterReceiver(addMapWidgetReceiver); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + addMapWidgetReceiver = null; } if (removeMapWidgetReceiver != null) { - mapActivity.unregisterReceiver(removeMapWidgetReceiver); + try { + mapActivity.unregisterReceiver(removeMapWidgetReceiver); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + removeMapWidgetReceiver = null; } widgetControls.clear(); if (addMapLayerReceiver != null) { - mapActivity.unregisterReceiver(addMapLayerReceiver); + try { + mapActivity.unregisterReceiver(addMapLayerReceiver); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + addMapLayerReceiver = null; } if (removeMapLayerReceiver != null) { - mapActivity.unregisterReceiver(removeMapLayerReceiver); + try { + mapActivity.unregisterReceiver(removeMapLayerReceiver); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + removeMapLayerReceiver = null; } }