I am currently integrating a google tap&pay SDK in my Flutter app. My app startActivityForResult the native Google wallet Activity to add a card to wallet. Now wallet Activity wants to startActivityForResult another activity in my app to get the verification code.
Now since all Flutter apps based on single activity architecture. If I start a new instance of the same Activity in my flutter app the session gets invalidated for the previous instance. So I cannot work with multiple instances of the same Activity.
How can I add another Activity in my Flutter app which will could be launched and share the same Flutter engine?
The diagram looks something like this:
A --> B --> C
- A: Flutter Activity
- B: Google Wallet Activity
- C: Another Activity for getting verification code
To add a second Android activity in your Flutter app, you can follow these steps:
MethodChannelto communicate between Flutter and native Android. Here is an example of how you can do this:And in your SecondActivity.java:
Please note that you need to replace
com.examplewith your own package name.FlutterEngineGroupclass. This allows you to share the same Flutter engine across multiple activities.