summaryrefslogtreecommitdiff
path: root/navit/android/src/org
diff options
context:
space:
mode:
authormvglasow <michael -at- vonglasow.com>2019-02-21 02:35:45 +0100
committermvglasow <michael -at- vonglasow.com>2019-02-21 02:35:45 +0100
commit2317c69710d1888077f50744d323ffaefaac4ddb (patch)
tree7a7bff4d8891e02e1b938bd20888ab3e3933a565 /navit/android/src/org
parentf6cea0c798c53eafa2f0e58a26e7c2fc607a3694 (diff)
downloadnavit-2317c69710d1888077f50744d323ffaefaac4ddb.tar.gz
Fix:port/android:Do not reinitialize everything on activity recreation
Signed-off-by: mvglasow <michael -at- vonglasow.com>
Diffstat (limited to 'navit/android/src/org')
-rw-r--r--navit/android/src/org/navitproject/navit/Navit.java20
-rw-r--r--navit/android/src/org/navitproject/navit/NavitGraphics.java2
-rw-r--r--navit/android/src/org/navitproject/navit/NavitSpeech2.java4
3 files changed, 18 insertions, 8 deletions
diff --git a/navit/android/src/org/navitproject/navit/Navit.java b/navit/android/src/org/navitproject/navit/Navit.java
index fb10d56dd..5c2d15a72 100644
--- a/navit/android/src/org/navitproject/navit/Navit.java
+++ b/navit/android/src/org/navitproject/navit/Navit.java
@@ -23,6 +23,7 @@ import android.Manifest;
import android.annotation.TargetApi;
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.Application;
import android.app.Dialog;
import android.app.Notification;
import android.app.NotificationManager;
@@ -71,6 +72,7 @@ import java.util.regex.Pattern;
public class Navit extends Activity {
+ protected static NavitGraphics graphics = null;
private NavitDialogs dialogs;
private PowerManager.WakeLock wl;
private NavitActivityResult[] ActivityResults;
@@ -97,7 +99,7 @@ public class Navit extends Activity {
Boolean isFullscreen = false;
private static final int MY_PERMISSIONS_REQUEST_ALL = 101;
private static NotificationManager nm;
- private static Navit navit;
+ private static Navit navit = null;
public static Navit getInstance() {
return navit;
@@ -316,6 +318,9 @@ public class Navit extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
+ /* Whether this is the first launch of Navit (as opposed to the activity being recreated) */
+ boolean isLaunch = (navit == null);
+
super.onCreate(savedInstanceState);
if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
@@ -442,8 +447,10 @@ public class Navit extends Activity {
}
Log.d(TAG, "android.os.Build.VERSION.SDK_INT=" + Integer.valueOf(android.os.Build.VERSION.SDK));
- NavitMain(this, NavitLanguage, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density,
- NAVIT_DATA_DIR + "/bin/navit", map_filename_path);
+ NavitMain(this, getApplication(), NavitLanguage, Integer.valueOf(android.os.Build.VERSION.SDK), my_display_density,
+ NAVIT_DATA_DIR + "/bin/navit", map_filename_path, isLaunch);
+ if (graphics != null)
+ graphics.setActivity(this);
showInfos();
@@ -833,7 +840,8 @@ public class Navit extends Activity {
}
break;
default :
- ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
+ if (ActivityResults[requestCode] != null)
+ ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data);
break;
}
}
@@ -908,8 +916,8 @@ public class Navit extends Activity {
NavitDestroy();
}
- public native void NavitMain(Navit x, String lang, int version, String display_density_string, String path,
- String path2);
+ public native void NavitMain(Navit x, Application application, String lang, int version,
+ String display_density_string, String path, String path2, boolean isLaunch);
public native void NavitDestroy();
diff --git a/navit/android/src/org/navitproject/navit/NavitGraphics.java b/navit/android/src/org/navitproject/navit/NavitGraphics.java
index c7430d1bc..4e7929f88 100644
--- a/navit/android/src/org/navitproject/navit/NavitGraphics.java
+++ b/navit/android/src/org/navitproject/navit/NavitGraphics.java
@@ -632,6 +632,8 @@ public class NavitGraphics {
* @param activity The main activity.
*/
protected void setActivity(final Activity activity) {
+ if (Navit.graphics == null)
+ Navit.graphics = this;
this.activity = (Navit) activity;
view = new NavitView(activity);
view.setClickable(false);
diff --git a/navit/android/src/org/navitproject/navit/NavitSpeech2.java b/navit/android/src/org/navitproject/navit/NavitSpeech2.java
index 1bf996dc5..c86fdd1c8 100644
--- a/navit/android/src/org/navitproject/navit/NavitSpeech2.java
+++ b/navit/android/src/org/navitproject/navit/NavitSpeech2.java
@@ -44,7 +44,7 @@ public class NavitSpeech2 implements TextToSpeech.OnInitListener, NavitActivityR
navit.startActivityForResult(checkIntent, MY_DATA_CHECK_CODE);
} else {
Log.e(TAG, "ACTION_CHECK_TTS_DATA not available, assume tts is working");
- mTts = new TextToSpeech(navit, this);
+ mTts = new TextToSpeech(navit.getApplication(), this);
}
}
@@ -57,7 +57,7 @@ public class NavitSpeech2 implements TextToSpeech.OnInitListener, NavitActivityR
if (requestCode == MY_DATA_CHECK_CODE) {
if (resultCode == TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
// success, create the TTS instance
- mTts = new TextToSpeech(navit, this);
+ mTts = new TextToSpeech(navit.getApplication(), this);
} else {
// missing data, ask to install it
AlertDialog.Builder builder = new AlertDialog.Builder(navit);