ACTION_BATTERY_LOW没有从清单中被解雇?

tyc*_*czj 2 android battery

是否action_battery_low允许从清单中被解雇,因为我认为它确实如此?

这是我的表现:

<reciever android:name=".BatteryReciever">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.BATTERY_LOW"/>
    </intent-filter>
</reciever>
Run Code Online (Sandbox Code Playgroud)

但是当我从系统获得低电量警告时,它永远不会被解雇.这只能被明确解雇吗?

Mr_*_*s_D 15

最初的问题表明接收者没有收到意图.这是因为接收器被声明<reciever>而不是<receiver>.如果接收器元素被正确声明,它就会起作用.

混淆的另一个主要原因是Android文档错误地引用"android.intent.action.ACTION_BATTERY_LOW""android.intent.action.ACTION_BATTERY_OKAY".此文档错误存在Android问题,但您应该知道有关该问题的一些评论会产生误导.

相反,接收者的行为必须是"android.intent.action.BATTERY_LOW""android.intent.action.BATTERY_OKAY".从Java源引用这些操作时,您可以使用正确定义的常量android.content.Intent.ACTION_BATTERY_LOWandroid.content.Intent.ACTION_BATTERY_OKAY.

不幸的是,Reto Meier也错误地定义了深潜到位置中的动作.此问题也已提出.