Igor Gaponov
Igor Gaponov

Reputation: 198

No Activity found to handle intent error using mailto link in flutter

I'm using documentation from url_launcher page: https://pub.dev/packages/url_launcher#android

AndroidManifest.xml:

<queries>
  <!-- other intents ... -->
  <intent>
    <action android:name="android.intent.action.SEND" />
    <data android:mimeType="*/*" />
  </intent>
</queries>

code:

final Uri emailLaunchUri = Uri(
  scheme: 'mailto',
  path: '[email protected]',
);

launch(emailLaunchUri.toString());

and getting the next error:

E/flutter (11956): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: PlatformException(ACTIVITY_NOT_FOUND, No Activity found to handle intent { mailto:[email protected] }, null, null)
E/flutter (11956): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:607:7)
E/flutter (11956): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:18)
E/flutter (11956): <asynchronous suspension>
E/flutter (11956): #2      launch (package:url_launcher/url_launcher.dart:99:23)
E/flutter (11956): <asynchronous suspension>
E/flutter (11956): #3      MoreTab.build.<anonymous closure> (package:app/screens/fixtures_screen/more_tab/more_tab.dart:34:13)
E/flutter (11956): <asynchronous suspension>

Upvotes: 7

Views: 7255

Answers (1)

L. Guthardt
L. Guthardt

Reputation: 2056

This could be caused by two issues:

First you need to add this intent to your AndroidManifest.xml or add the queries element if it doesnt exist yet, like explained in the documentation. Add queries as a child of the manifest element.

<manifest>
    ...other stuff
    <queries>    
        ... other intents
        <!-- If your app sends emails -->
        <intent>
            <action android:name="android.intent.action.SEND" />
            <data android:mimeType="*/*" />
        </intent>
    </queries>
</manifest>

If this doesnt fix it, the issue might be your emulator.

I had this exact issue as well or that canLaunch() returned only false while I was testing the app on an emulator. The issue on an emulator could be that no mail app is installed, therefor the mail url can not be launched.

So try it out on a real device, it should work fine there.

Upvotes: 4

Related Questions