floating
floating copied to clipboard
IllegalStateException when trying to enter PiP mode from SplitScreen
I am running Flutter version 3.7.11 and the newest version of the floating package. Moreover, I use the following code to enter Pip Mode:
@override
void didChangeAppLifecycleState(AppLifecycleState lifecycleState) {
if (_pipIsSupported) { // only true if '!kIsWeb && Platform.isAndroid'
if (lifecycleState == AppLifecycleState.inactive) {
// Only enable PiP if the timer is currently running
if (state.mode != ModeRegister.IDLE) {
_floating.enable();
}
}
}
}
However, I run into issues in the following two situation:
- On a phone (Pixel 6 Emulator on API level 33):
- Open the app
- Enter App Overview
- Click on the App icon and then on 'Split top'
- On a tablet (10.1 WXGA Emulator on API lebel 33):
- Open the app in split screen mode
- Use the central divider to put the other app into fullscreen
In both of these cases I get the following exception:
E/flutter ( 6443): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Activity must be resumed to enter picture-in-picture, null, java.lang.IllegalStateException: Activity must be resumed to enter picture-in-picture
E/flutter ( 6443): at android.app.Activity.enterPictureInPictureMode(Activity.java:2901)
E/flutter ( 6443): at eu.wroblewscy.marcin.floating.floating.FloatingPlugin.onMethodCall(FloatingPlugin.kt:61)
E/flutter ( 6443): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/flutter ( 6443): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/flutter ( 6443): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/flutter ( 6443): at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/flutter ( 6443): at android.os.Handler.handleCallback(Handler.java:942)
E/flutter ( 6443): at android.os.Handler.dispatchMessage(Handler.java:99)
E/flutter ( 6443): at android.os.Looper.loopOnce(Looper.java:201)
E/flutter ( 6443): at android.os.Looper.loop(Looper.java:288)
E/flutter ( 6443): at android.app.ActivityThread.main(ActivityThread.java:7872)
E/flutter ( 6443): at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 6443): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
E/flutter ( 6443): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/flutter ( 6443): )
E/flutter ( 6443): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:653:7)
E/flutter ( 6443): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:315:18)
E/flutter ( 6443): <asynchronous suspension>
E/flutter ( 6443): #2 Floating.enable (package:floating/src/floating.dart:83:39)
E/flutter ( 6443): <asynchronous suspension>
E/flutter ( 6443):
Any chance that this can be fixed?