<data android:type =“* / *”>不允许使用字符串类型

时间:2017-03-26 15:03:29

标签: java android

我试图在我的应用上设置过滤器,因此我可以收听不同的电子邮件应用程序,但我总是收到错误:&#34; String type not allowed at <data android:type="*/*" />&#34;

我如何更改它以便它可以收听我的所有电子邮件应用程序,以及如何更改它以便我可以收听特定的应用程序而不是所有应用程序?

这是我的清单

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

3 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

答案 2 :(得分:-1)

<data> has no android:type

我认为你想要MIME类型,所以android:mimeType="*/*"