From 6c84a712d3f668fdeebfa3c54b196b0b9eae676b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sat, 5 Sep 2015 21:40:18 +0200 Subject: [PATCH] Fix data loss in connection with geo: intents. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When geo: intents are handled by activities created in a different task, that can lead to the same map being opened multiple times (once in each task). The way the maps are implemented, this means that the last to call onPause/onDestroy will "win" its reference points will end up on disk. This is particularly annoying if that one is the one that has no reference points and you lost all that you added... Solve it via a horrible hack that always uses a new, clean task (of which there should be only one). Signed-off-by: Reimar Döffinger --- .../hu_berlin/informatik/spws2014/mapever/Start.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/MapEver/src/de/hu_berlin/informatik/spws2014/mapever/Start.java b/MapEver/src/de/hu_berlin/informatik/spws2014/mapever/Start.java index d036ddb..0fbeb95 100644 --- a/MapEver/src/de/hu_berlin/informatik/spws2014/mapever/Start.java +++ b/MapEver/src/de/hu_berlin/informatik/spws2014/mapever/Start.java @@ -114,6 +114,17 @@ protected void onCreate(Bundle savedInstanceState) { Log.d("Start", "onCreate..." + (savedInstanceState != null ? " with savedInstanceState" : "")); super.onCreate(savedInstanceState); + // We do not want to have multiple instances, as that ends up with race + // conditions on reading/writing the data files. + // Using singleTask for this is simply broken. + // So instead forward the intent to a "clean" task if necessary + if (!isTaskRoot() && (getIntent().getFlags() & (Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK)) == 0) { + getIntent().setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(getIntent()); + finish(); + return; + } + if (savedInstanceState == null) { Intent intent = getIntent(); if (intent != null && intent.getBooleanExtra(INTENT_EXIT, false)) {