ACTION_BATTERY_LOW没有从清单解雇?清单、ACTION_BATTERY_LOW

2023-09-07 02:48:45 作者:她曾是我的黎明

确实 action_battery_low 允许被从清单中解雇了,因为我觉得它没有?

Does action_battery_low allow being fired from the manifest because I thought it did?

下面是我的表现吧:

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

但它从来没有得到的时候,我得到来自系统的低电量警告射击。可这只是明确解雇?

But it never gets fired when I get the low battery warning from the system. Can this only be fired explicitly?

推荐答案

原来的问题指出,接收不接收意图。这是因为接收器被宣布为&LT; reciever&GT; ,而不是&LT;接收器&GT; 。有接收器元件被正确地宣布,它会奏效。

The original question states that the receiver does not receive intents. This is because the receiver was declared as <reciever> rather than <receiver>. Had the receiver element been declared correctly, it would have worked.

混乱的另一个主要来源是, Android的文档错误地引用android.intent.action.ACTION_BATTERY_LOWandroid.intent.action .ACTION_BATTERY_OKAY。有一个现有的 Android的问题此文档错误,但你应该知道一些关于这个问题的意见是误导性的。

Another major source of confusion is the fact that the Android documentation incorrectly references "android.intent.action.ACTION_BATTERY_LOW" and "android.intent.action.ACTION_BATTERY_OKAY". There is an existing Android Issue for this documentation error, but you should be aware that some of the comments on that issue are misleading.

相反,接收器的行为必须是android.intent.action.BATTERY_LOWandroid.intent.action.BATTERY_OKAY。当引用从Java源代码这些操作,您可以使用常量 android.content。 Intent.ACTION_BATTERY_LOW 和 android.content.Intent.ACTION_BATTERY_OKAY 这是正确定义。

Instead, the receiver's actions must be "android.intent.action.BATTERY_LOW" and "android.intent.action.BATTERY_OKAY". When referencing these actions from Java source, you may use the constants android.content.Intent.ACTION_BATTERY_LOW and android.content.Intent.ACTION_BATTERY_OKAY which are defined correctly.

不幸的是雷托•梅耶尔还错误地定义 A中的作用深入了解位置。一个问题已经提交了解这一点。

Unfortunately Reto Meier also incorrectly defines the action in A Deep Dive Into Location. An issue has been filed for this as well.