Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In a multi-activity app, the plugin doesn't reattach to the first activity #732

Closed
5 tasks done
MElkady opened this issue Mar 18, 2021 · 5 comments
Closed
5 tasks done
Labels
bug Something isn't working

Comments

@MElkady
Copy link

MElkady commented Mar 18, 2021

Environment

Technology Version
Flutter version 1.22.6
Plugin version 4.0.0+4
Android version 10
iOS version Not relevant
Xcode version Not relevant

Device information: Samsung Galaxy S8

Description

In an application that consists of multiple flutter activities. The plugin attaches only to the topmost activity. After that activity finishes, Shared.activity will become null & none of the other activities can use the plugin

Steps to reproduce

  1. Create a flutter application with flutter_inappwebview plugin
  2. Then add an additional FlutterActivity (I do that to start a special routine for some use cases)
  3. Then build and run the app
  4. Then open the main activity (then Shared.activity will point to the main activity)
  5. Then open the 2nd activity (then Shared.activity will point to the 2nd activity)
  6. Return to the main activity & try to open the wevbiew
  7. Notice that it doesn't work & a null pointer exception is thrown

Stacktrace/Logcat

[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Class java.lang.Object.getClass()' on a null object reference
        at com.pichillilorenzo.flutter_inappwebview.ChromeSafariBrowserManager.open(ChromeSafariBrowserManager.java:66)
        at com.pichillilorenzo.flutter_inappwebview.ChromeSafariBrowserManager.onMethodCall(ChromeSafariBrowserManager.java:49)
        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:326)
        at android.os.Looper.loop(Looper.java:181)
        at android.app.ActivityThread.main(ActivityThread.java:7050)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
@MElkady MElkady added the bug Something isn't working label Mar 18, 2021
@pichillilorenzo
Copy link
Owner

Did you try the latest version of the plugin and the latest of flutter?? Version 4 is not supported anymore.

However, the plugin already implements the ActivityAware flutter interface and support the onAttachedToActivity and onReattachedToActivityForConfigChanges events (just check the Android InAppWebViewFlutterPlugin.java class).
So, I don't know if you need to do something more specific when you move from one Android FlutterActivity to another, but this should already work (I think). It could be also a Flutter issue.
Also, could you create a simple project with that scenario? Thanks.

@no-response
Copy link

no-response bot commented Mar 27, 2021

This issue has been automatically closed because it was marked as "answered", and there wasn't any recent activity on this issue.

@no-response no-response bot closed this as completed Mar 27, 2021
@pichillilorenzo
Copy link
Owner

I was able to reproduce the error! The fix should come with the next release!

@no-response no-response bot closed this as completed Mar 27, 2021
Repository owner deleted a comment from no-response bot Mar 27, 2021
@pichillilorenzo
Copy link
Owner

Fixed with new release 5.3.0!

Copy link

github-actions bot commented Nov 5, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants