]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix task-switching failures on Android 2.3
authorPo Lu <luangruo@yahoo.com>
Sat, 13 Apr 2024 03:28:23 +0000 (11:28 +0800)
committerEshel Yaron <me@eshelyaron.com>
Sun, 14 Apr 2024 17:09:39 +0000 (19:09 +0200)
* java/org/gnu/emacs/EmacsWindowManager.java (registerWindow):
Don't specify F_A_MULTIPLE_TASK on Android 4.4 and earlier.

(cherry picked from commit 4fc37710788cdab9ebf4264636999ba999a59547)

java/org/gnu/emacs/EmacsWindowManager.java

index e41b4e068a76046f8c48878ed9c83e5bb25258a9..a193d49d0ecec55b875c275f0fa1deb88b39e273 100644 (file)
@@ -176,14 +176,20 @@ public final class EmacsWindowManager
     intent = new Intent (EmacsService.SERVICE,
                         EmacsMultitaskActivity.class);
 
-    intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK
-                    | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
+    /* FLAG_ACTIVITY_MULTIPLE_TASK would appear appropriate, but that
+       is not so: on Android 2.3 and earlier, this flag combined with
+       FLAG_ACTIVITY_NEW_TASK prompts the task switcher to create a
+       new instance of EmacsMultitaskActivity, rather than return to
+       an existing instance, and is entirely redundant, inasmuch as
+       only one multitasking task can exist at any given moment.  */
+    intent.addFlags (Intent.FLAG_ACTIVITY_NEW_TASK);
 
     /* Intent.FLAG_ACTIVITY_NEW_DOCUMENT is lamentably unavailable on
        older systems than Lolipop.  */
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
       {
-       intent.addFlags (Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
+       intent.addFlags (Intent.FLAG_ACTIVITY_NEW_DOCUMENT
+                        | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
 
        /* Bind this window to the activity in advance, i.e., before its
           creation, so that its ID will be recorded in the RecentTasks