Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make my Android app appear in the app chooser when emailing a WhatsApp chat?

I am interested in making my app appear in the apps list shown when I use the "email conversation" feature in WhatsApp.

When logging my phone while using the "email conversation" WhatsApp feature I can see a SEND_MULTIPLE intent being received by Gmail:

I/ActivityManager(  859): START u0 {act=android.intent.action.SEND_MULTIPLE typ=text/* flg=0xb080001 pkg=com.google.android.gm cmp=com.google.android.gm/.ComposeActivityGmail (has clip) (has extras)} from uid 10114 on display 0

So I suppose I need to add an intent filter for the SEND_MULTIPLE action in my app manifest.

Currently my AndroidManifest.xml is:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="co.xxx.xxx" >


<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme" >


    <activity
        android:name=".MyActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>


        <intent-filter>
            <action android:name="android.intent.action.SENDTO" />

            <data android:scheme="mailto" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <data android:scheme="mailto" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.SEND_MULTIPLE" />

            <data android:mimeType="*/*" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.SEND" />

            <data android:mimeType="*/*" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

    </activity>

</application>

</manifest>

However, when I run my app in my phone via Android Studio, it does not show up when trying to export my WhatsApp conversation. Conversely, it shows up in the app chooser when trying to share a picture of my gallery.

What am I missing in the AndroidManifest that prevents my app from being shown when emailing my WhatsApp conversations? Is there something else I need to announce to the OS to make my app elligible for appearing in the app chooser?

I have tried to install K-9 Mail app. Just after installing it, it does not appear in the app chooser when emailing a chat in WhatsApp, but after setting up an account in K-9, it appears in the chooser. Is it possible that K9 announces to the OS that it is ready for sending emails?

Thank you!

like image 679
pau.moreno Avatar asked Oct 11 '15 16:10

pau.moreno


1 Answers

Unfortunately even if your manifest is properly configured you cannot see your app in the app chooser when emailing a chat because your app need to be whitelisted by WhatsApp. Only the chosen package names will be available in the WhatsApp's app chooser.

For example we have an app with the package name com.example.whatsappemailchat. The AndroidManifest.xml is something like this:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.whatsappemailchat" >

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

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SENDTO"/>
                <data android:scheme="mailto"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND"/>
                <data android:mimeType="*/*"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEND_MULTIPLE"/>
                <data android:mimeType="*/*"/>
                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <data android:scheme="mailto"/>

                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
            </intent-filter>
        </activity>
    </application>

</manifest>

and this is the build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.example.whatsappemailchat"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Everything is correctly configured, we run our application, but if we choose More > Email chat our app will not appear.

Now change the applicationId to com.google.android.gm.test (the package name of Gmail plus .test as suffix to avoid collision with real Gmail) in our build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.google.android.gm.test"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

Now run our application, open WhatsApp, select a chat, choose More > Email chat and magically our app will be in the app chooser, as you can see in this screenshot:

enter image description here

I can confirm that these package names are whitelisted by WhatsApp:

  • com.google.android.gm
  • com.fsck.k9
  • com.boxer.email
  • com.google.android.email

I think that the only viable solution is to try to contact WhatsApp and ask if it's possible to whitelist your package name.

like image 101
Mattia Maestrini Avatar answered Nov 03 '22 20:11

Mattia Maestrini