2

My Navigation Drawer includes an option to contact the developer via email. To do this I've included code in accordance with the documentation. However, when clicking on 'Contact Developer,' the options shown include my app, which is not capable of email. I've searched online for this issue but haven't found anything relevant. How do I limit the user's options to email-apps only? The method from MainActivity.java and intent-filter from AndroidManfiest are included below.

MainActivity.java

    //METHOD: Allow user's to send email to developer
    public void composeEmail() {
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
        emailIntent.setData(Uri.parse("mailto:")); // only email apps should handle this
        emailIntent.putExtra(Intent.EXTRA_EMAIL, "contact@developer.com");
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Email subject");
        if (emailIntent.resolveActivity(getPackageManager()) != null) {
            startActivity(emailIntent);
        }
    }

AndroidManifest.xml

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.Launcher">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <!--Intent filter for sending email-->
            <intent-filter>
                <action android:name="android.intent.action.SENDTO" />
                <data android:scheme="mailto" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>
    </application>
Samm
  • 115
  • 12

1 Answers1

0

@Mike M. had the right answer.

That second intent-filter is saying that your app does handle email. You don't need that to be able to just send email. Remove that, and your app should no longer show as an option. – Mike M.

I had unnecessarily copied the Example intent filter: from the documentation. Editing AndroidManifest.xml to the below code has solved the problem.

<application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme.Launcher">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
Samm
  • 115
  • 12