Short Question: startActivityAndCollapse not working for Android 13
Long Question: I am creating a tile for the quick settings panel. I have tried to implement this demo. It's working fine for all other devices except Android 13
override fun onClick() {
super.onClick()
try {
val newIntent =
FlutterActivity.withNewEngine().dartEntrypointArgs(listOf("launchFromQuickTile"))
.build(this)
newIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivityAndCollapse(newIntent)
} catch (e: Exception) {
Log.d("debug", "Exception ${e.toString()}")
}
}
The above code is working to open the application but it's not collapsing the quick settings panel.
Is there any solution, any help?
Edited:
I had taken a look more into this and found that It's working only If I pass the Android activity.
Example (Android):
val newIntent = Intent(this, MainActivity::class.java)
newIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivityAndCollapse(newIntent)
Example (Flutter):
val newIntent = FlutterActivity.withNewEngine().dartEntrypointArgs(listOf("launchFromQuickTile")).build(this)
newIntent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
startActivityAndCollapse(newIntent)
Is there any other way to open Flutter App with Params?
I tried the following code and it worked. I used https://github.com/android/user-interface-samples/tree/main/Quick-Settings sample app.
AndroidManifest.xml
MainActivity.kt
TileService.kt
build.gradle
main.dart
pubspec.
Output I/flutter: [launchFromQuickTile]
Stackoverflow does not allow video embedding hence I uploaded the working on Youtube. You can see the video here https://youtu.be/W_iM2yR_07Y