Skip to content

Commit 4926c0f

Browse files
authored
[quick_actions] Add guidance for correcting task management/back press behavior for apps with launcher activities (#7686)
### What Adds a note about correcting the task management/back press behavior for apps that use launcher activities to the `README`. Fixes flutter/flutter#152883. ### Why If apps use a launcher activity, then launching shortcuts created by the plugin may not behave as expected because the plugin expects to launch the main `FlutterActivity`, for which it configures the launch mode, but instead launches the launcher activity, which it does not account for. To fix this, the launcher activity itself needs to have a launch mode configuration that makes sense for the app. This involves changing the launch mode of the launcher activity in the manifest and/or using the right `Intent` flags to launch the main `FlutterActivity`. From my work on the issue linked above, I found that if the launcher activity only launches the main `FlutterActivity` without any additional relevant logic, to maintain the exact same behavior of the plugin with/without a launcher activity, the launcher activity can use the `singleInstance` launch mode. So, I included a note about this. However, in more complex launcher activities, like b/357028168 that inspired the original issue, other modes may need to be used.
1 parent 21d99dc commit 4926c0f

File tree

6 files changed

+36
-3
lines changed

6 files changed

+36
-3
lines changed

packages/quick_actions/quick_actions/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## NEXT
1+
## 1.0.8
22

33
* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.
4+
* Adds reference to `quick_actions_android` README in the Android section of the README.
45

56
## 1.0.7
67

packages/quick_actions/quick_actions/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ If the drawables used as icons are not referenced other than in your Dart code,
5252
you may need to
5353
[explicitly mark them to be kept](https://developer.android.com/studio/build/shrink-code#keep-resources)
5454
to ensure that they will be available for use in release builds.
55+
56+
For more information on using this package on Android, see the
57+
[`quick_actions_android` README](https://github.com/flutter/packages/blob/main/packages/quick_actions/quick_actions_android/README.md).

packages/quick_actions/quick_actions/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for creating shortcuts on home screen, also known as
33
Quick Actions on iOS and App Shortcuts on Android.
44
repository: https://github.com/flutter/packages/tree/main/packages/quick_actions/quick_actions
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+quick_actions%22
6-
version: 1.0.7
6+
version: 1.0.8
77

88
environment:
99
sdk: ^3.3.0

packages/quick_actions/quick_actions_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.16
2+
3+
* Updates README to include guidance on using the plugin with a launcher activity.
4+
15
## 1.0.15
26

37
* Updates lint checks to ignore NewerVersionAvailable.

packages/quick_actions/quick_actions_android/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,35 @@ so you do not need to add it to your `pubspec.yaml`.
1111
However, if you `import` this package to use any of its APIs directly, you
1212
should add it to your `pubspec.yaml` as usual.
1313

14+
## Usage with launcher activities
15+
16+
If your app implements an activity that launches the main `FlutterActivity`
17+
(`MainActivity.java`/`MainActivity.kt` by default), then you may need to change
18+
the launch mode of your launcher activity and/or modify the `Intent` flags used
19+
to launch the main `FlutterActivity` in order to achieve the desired back press
20+
behavior and task management.
21+
22+
If your launcher activity only launches the main `FlutterActivity` without any
23+
additional relevant logic (like the code sample provided in the description of
24+
https://github.com/flutter/flutter/issues/152883), to have your app maintain the
25+
same behavior of `quick_actions_android` with/without a launcher activity, set
26+
the launch mode of your launcher activity to `singleInstance` in
27+
`your_app/android/app/src/mainAndroidManifest.xml`:
28+
29+
```xml
30+
<activity
31+
...
32+
android:launchMode="singleInstance">
33+
```
34+
35+
See the [Tasks and the back stack][4] Android documentation for more information
36+
on the different launch modes and `Intent` flags you may need.
37+
1438
## Contributing
1539

1640
If you would like to contribute to the plugin, check out our [contribution guide][3].
1741

1842
[1]: https://pub.dev/packages/quick_actions
1943
[2]: https://flutter.dev/to/endorsed-federated-plugin
2044
[3]: https://github.com/flutter/packages/blob/main/CONTRIBUTING.md
45+
[4]: https://developer.android.com/guide/components/activities/tasks-and-back-stack#TaskLaunchModes

packages/quick_actions/quick_actions_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: quick_actions_android
22
description: An implementation for the Android platform of the Flutter `quick_actions` plugin.
33
repository: https://github.com/flutter/packages/tree/main/packages/quick_actions/quick_actions_android
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
5-
version: 1.0.15
5+
version: 1.0.16
66

77
environment:
88
sdk: ^3.4.0

0 commit comments

Comments
 (0)