gpt4 book ai didi

android - ACTION_BATTERY_LOW 未从 list 中解雇?

转载 作者:太空狗 更新时间:2023-10-29 15:31:07 28 4
gpt4 key购买 nike

action_battery_low 是否允许从 list 中触发,因为我认为是这样?

这是我的 list :

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

但当我从系统收到低电量警告时,它永远不会被触发。只能显式触发吗?

最佳答案

原始问题指出接收者没有收到 Intent 。这是因为接收器被声明为 <reciever>而不是 <receiver> .如果接收器元素被正确声明,它就会工作。

另一个主要的混淆来源是 the Android documentation错误引用 "android.intent.action.ACTION_BATTERY_LOW""android.intent.action.ACTION_BATTERY_OKAY" .有一个现有的 Android Issue对于此文档错误,但您应该意识到关于该问题的一些评论具有误导性。

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

不幸的是,Reto Meier 也错误地定义了 A Deep Dive Into Location 中的 Action .一个问题has been filed也是为了这个。

关于android - ACTION_BATTERY_LOW 未从 list 中解雇?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5393651/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com