>我正在尝试在我的应用程序上设置过滤器,以便我可以收听我不同的电子邮件应用程序,但我总是收到错误:"String type not allowed at <data android:type="*/*" />
它可以侦听我的所有电子邮件应用程序,以及如何更改它以便我可以收听特定的应用程序而不是所有应用程序?
这是我的清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.filipecosta.mytasks">
<uses-permission android:name="android.permission.CALL_PHONE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".TaskActivity">
<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.SEND" />
<data android:type="*/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name=".PhoneCall"></activity>
</application>
</manifest>
没有属性type
<data>
。只需使用android:mimeType
而不是android:type
试试这个:
<intent-filter>
<action android:name="android.intent.action.SEND" />
<data android:mimeType="*/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
详情: https://developer.android.com/guide/topics/manifest/data-element.html
中没有属性type
只是mimeType
.
https://developer.android.com/guide/topics/manifest/intent-filter-element.html?hl=en-419
<data>
没有android:type
我想你想要MIME类型,所以android:mimeType="*/*"
.