不幸的是,即使您的清单配置正确,您在通过电子邮件发送聊天时也无法在应用程序选择器中看到您的应用程序,因为您的应用程序需要被 WhatsApp 列入白名单。 WhatsApp 的应用程序选择器中仅提供所选的软件包名称。
例如我们有一个应用程序的包名称com.example.whatsappemailchat
. The AndroidManifest.xml
是这样的:
<?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
我们的应用程序将不会出现。
现在改变applicationId
to com.google.android.gm.test
(Gmail plus 的包名.test
作为后缀以避免与真正的 Gmail 冲突)在我们的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
神奇的是,我们的应用程序将出现在应用程序选择器中,正如您在此屏幕截图中所看到的:
![enter image description here](https://i.stack.imgur.com/G6s7Qm.jpg)
我可以确认这些软件包名称已被 WhatsApp 列入白名单:
- com.google.android.gm
- com.fsck.k9
- com.boxer.email
- com.google.android.电子邮件
我认为唯一可行的解决方案是尝试联系 WhatsApp 并询问是否可以将您的软件包名称列入白名单。