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

1,515

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.

Share:
1,515
Igor Gaponov
Author by

Igor Gaponov

Updated on December 01, 2022

Comments

  • Igor Gaponov
    Igor Gaponov over 1 year

    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>
    
  • Igor Gaponov
    Igor Gaponov about 2 years
    The problem was indeed in the emulator, thanks!