使用receiverandroid时出错

时间:2013-01-10 11:06:03

标签: android android-intent broadcastreceiver android-manifest

这是我的manifest.xml文件的摘录:

<receiverandroid:name=".SmsReceiver">
        <intent-filter>
            <actionandroid:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
</receiver>

编译代码时,我在控制台中收到以下错误:

Element type "receiverandroid:name" must be followed by either attribute specifications, ">" or "/>"

这实际上不是我做的吗?为什么我会收到此错误?

2 个答案:

答案 0 :(得分:3)

<receiverandroid:name<actionandroid:name

中留出空格
<receiver android:name=".SmsReceiver">
        <intent-filter>
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
</receiver>

答案 1 :(得分:2)

将您的接收者声明为:

<receiver android:name=".SmsReceiver">
        <intent-filter>
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
</receiver>

目前您组合了标记名称和属性。在标签和属性之间留出空间