Browse Source

SDK: Add SingleTask Launch Mode to AndroidManifest for new projects to avoid starting a new instance of the app when users hit the Home button and then resume the app.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10627 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
iwg..om 12 years ago
parent
commit
caaf8ba22e
1 changed files with 22 additions and 0 deletions
  1. 22 0
      jme3-android/src/com/jme3/gde/android/AndroidSdkTool.java

+ 22 - 0
jme3-android/src/com/jme3/gde/android/AndroidSdkTool.java

@@ -290,6 +290,28 @@ public class AndroidSdkTool {
             in.close();
             in = null;
             boolean changed = false;
+            Element sdkApplication = XmlHelper.findChildElement(configuration.getDocumentElement(), "application");
+            if (sdkApplication != null) {
+                Element sdkActivity = XmlHelper.findChildElement(sdkApplication, "activity");
+                if (sdkActivity != null) {
+                    if (!sdkActivity.hasAttribute("android:launchMode")) {
+                        sdkActivity.setAttribute("android:launchMode", "singleTask");
+                        changed = true;
+                    }
+                }
+                // add the following after AndroidHarness.screenOrientation is depreciated
+                //   for jME 3.1
+//                if (sdkActivity != null) {
+//                    if (sdkActivity.hasAttribute("android:screenOrientation")) {
+//                        String attrScreenOrientation = sdkActivity.getAttribute("android:screenOrientation");
+//                    } else {
+//                        Logger.getLogger(AndroidSdkTool.class.getName()).log(Level.INFO, "creating attrScreenOrientation");
+//                        sdkActivity.setAttribute("android:screenOrientation", "landscape");
+//                        changed = true;
+//                    }
+//                }
+            }
+
             Element sdkElement = XmlHelper.findChildElement(configuration.getDocumentElement(), "uses-sdk");
             if (sdkElement == null) {
                 sdkElement = configuration.createElement("uses-sdk");