我是使用dom4j来解析AndroidManifestFile.xml文件的。然而,我发现它对"android:xxx"属性的处理方式很奇怪。
例如:
例如:
<receiver android:name="ProcessOutgoingCallTest" android:exported="false"
android:enabled="false">
<intent-filter android:priority="1">
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
返回值e.attributeValue("android:exported")
将为null
,但是使用e.attributeValue("exported")
将获得正确的字符串(但我不喜欢这种方式,因为它可能匹配更多的内容)。与此同时,e.attributeValue(new QName("android:exported"))
仍然是一个空字符串。
获取属性的正确方式是什么?
QName
和命名空间相关的内容。 - chenzhongpu