我是否可以将我的应用列入该列表?
不,很遗憾,这是不可能的,即使您的清单配置正确,当您选择 Share -> Send to 时您也看不到您的应用,因为 Spotify 将仅显示一组预定义的应用(WhatsApp、Facebook Messenger、环聊)。
例如,我们有一个应用程序包名称为com.example.spotify。将此intent-filter 添加到AndroidManifest.xml:
<intent-filter>
<action android:name="android.intent.action.SEND"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/plain"/>
</intent-filter>
运行应用程序,但如果我们选择Share -> Send to,应用程序将不会出现。
现在在我们的 build.gradle 中将 applicationId 更改为列入白名单的包名称之一(com.whatsapp、com.facebook.orca、com.google.android.talk):
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.whatsapp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
现在该应用程序可以在 Share -> Send to 上下文菜单中使用,就像 WhatsApp 一样,您可以在此屏幕截图中看到:
选择 WhatsApp,我们的应用将正确打开并接收来自 Spotify 的意图。