通过电子邮件发送WhatsApp聊天时,如何使我的Android应用出现在应用选择器中? [英] How to make my Android app appear in the app chooser when emailing a WhatsApp chat?

查看:95
本文介绍了通过电子邮件发送WhatsApp聊天时,如何使我的Android应用出现在应用选择器中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用WhatsApp中的电子邮件对话"功能时,我有兴趣让我的应用程序出现在显示的应用程序列表中.

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

使用电子邮件对话" WhatsApp功能登录手机时,我可以看到Gmail收到了SEND_MULTIPLE意图:

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

所以我想我需要在我的应用清单中为SEND_MULTIPLE操作添加一个意图过滤器.

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

当前我的AndroidManifest.xml是:

<?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>

但是,当我通过Android Studio在手机中运行我的应用程序时,在尝试导出WhatsApp对话时却没有显示.相反,在尝试共享我的画廊的图片时,它会显示在应用选择器中.

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.

我在AndroidManifest中缺少什么,从而在通过电子邮件发送WhatsApp对话时无法显示我的应用程序?我还需要向OS宣布一些其他信息,以使我的应用易于显示在应用选择器中吗?

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?

我尝试安装 K-9邮件应用.刚安装后,在WhatsApp中通过电子邮件发送聊天时,它不会出现在应用选择器中,但是在K-9中设置了帐户后,它就会显示在选择器中. K9是否有可能向操作系统宣布已准备好发送电子邮件?

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?

谢谢!

推荐答案

不幸的是,即使您的清单配置正确,通过电子邮件发送聊天时,您也无法在应用选择器中看到您的应用,因为WhatsApp需要将您的应用列入白名单.在WhatsApp的应用选择器中只有可用的软件包名称.

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.

例如,我们有一个应用程序,其程序包名称为com.example.whatsappemailchat. AndroidManifest.xml是这样的:

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>

这是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'
        }
    }
}

所有内容均已正确配置,我们将运行我们的应用程序,但如果选择More > Email chat,则我们的应用程序将不会显示.

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

现在在我们的build.gradle中将applicationId更改为com.google.android.gm.test(Gmail加.test的包名作为后缀,以避免与真实的Gmail冲突):

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'
        }
    }
}

现在运行我们的应用程序,打开WhatsApp,选择一个聊天,然后选择More > Email chat,然后我们的应用程序将神奇地出现在应用程序选择器中,如下面的屏幕截图所示:

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:

我可以确认WhatsApp将这些软件包名称列入白名单:

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

我认为唯一可行的解​​决方案是尝试联系WhatsApp,并询问是否可以将您的软件包名称列入白名单.

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

这篇关于通过电子邮件发送WhatsApp聊天时,如何使我的Android应用出现在应用选择器中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆