bostrot / bostrot/flutter_android_pip

Failed to handle method call: Attempt to invoke virtual method 'void android.app.Activity.enterPictureInPictureMode()' on a null object reference

Open
#8 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
14
Forks
14
PR merge metrics
No merged PRs in 30d

Description

I am using flutter_android_pip in my Flutter app to enter PiP mode instead of minimizing the app (when user presses home).
It worked fine with code like this:
```
class _MyWidgetState extends State with WidgetsBindingObserver {
...
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.inactive) {
_enterPipMode();
}
else if (state == AppLifecycleState.resumed) {
_exitPipMode();
}
}
...
}
```

After I have installed Firebase it stopped working with following error:
```
Failed to handle method call
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.Activity.enterPictureInPictureMode()' on a null object reference
at com.bostrot.flutterandroidpip.FlutterAndroidPipPlugin.onMethodCall(FlutterAndroidPipPlugin.java:26)
at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:692)
at android.os.MessageQueue.nativePollOnce(Native Method)
at android.os.MessageQueue.next(MessageQueue.java:325)
at android.os.Looper.loop(Looper.java:142)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
```

Note, it still works if Firebase is not initialized in the code.

Also noted deprecation warning on both plugins:
```
Note: /.../firebase_core-0.7.0/android/src/main/java/io/flutter/plugins/firebase/core/FlutterFirebaseCorePlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /.../firebase_messaging-8.0.0-dev.15/android/src/main/java/io/flutter/plugins/firebase/messaging/FlutterFirebaseMessagingPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /.../flutter_android_pip-0.0.2/android/src/main/java/com/bostrot/flutterandroidpip/FlutterAndroidPipPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
```

Are these plugins incompatible in some way?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.