website icon indicating copy to clipboard operation
website copied to clipboard

Update Android Intent handling on 'Flutter for Android developers' page

Open palucdev opened this issue 5 years ago • 3 comments

Hello!

I have simple communication case where android application is launching flutter application with intent containing some extra string data (using putExtra() method). Found official docs with guide how to handle such situations but unfortunetaly provided code from docs do not work as it uses io.flutter.app.FlutterActivity package.

Using io.flutter.embedding.android.FlutterActivity results in problem with GeneratedPluginRegistrant.registerWith(this); line, as .registerWith() expects to have FlutterEngine param, not MainActivity one.

Using suggested code for io.flutter.embedding.android.FlutterActivity :

@Override
public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine) {
    GeneratedPluginRegistrant.registerWith(flutterEngine);
}

results in problem with MethodChannel seen below (do I still need to call some registration method in onCreate() )?

MissingPluginException(No implementation found for method getSharedText on channel app.channel.shared.data)
#0     MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:319:7)

Can someone provide me with usable solution on how to handle Intents in Flutter (v1.12.13+hotfix.9)? It will be good to update docs too, now it is more confusing than helpful.

Thanks in advance!

palucdev avatar Apr 09 '20 15:04 palucdev