Android Intent.ACTION屏幕关闭,Intent.ACTION用户演示如何注册
在我的主要活动中Android Intent.ACTION屏幕关闭,Intent.ACTION用户演示如何注册,android,Android,在我的主要活动中 Activity has leaked IntentReceiver ScreenReceiver that was originally registered here. Are you missing a call to unregisterReceiver()? 当应用程序关闭时,我收到这个消息 // Register receiver that handles screen on and screen off logic final IntentFilter in
Activity has leaked IntentReceiver ScreenReceiver that was originally registered here. Are you missing a call to unregisterReceiver()?
当应用程序关闭时,我收到这个消息
// Register receiver that handles screen on and screen off logic
final IntentFilter intentScreenfilter = new IntentFilter(Intent.ACTION_SCREEN_ON);
intentScreenfilter.addAction(Intent.ACTION_SCREEN_OFF);
intentScreenfilter.addAction(Intent.ACTION_USER_PRESENT);
screenReceiver = new ScreenReceiver();
及
无法在AndroidManifest中注册,但只能以编程方式注册。我能做什么?我不想使用服务,因为如果服务整天运行,这对电池不好。解决办法是什么?如何使用此接收器?您不能从android清单文件注册这些接收器。根本不支持。唯一的方法是长时间运行服务,并在服务中注册这些接收器。所以如果你真的想用
ACTION_SCREEN_ON
及
然后您必须使用服务是的,这对性能有害,运行服务会消耗更多电池。即使我是在这些接收器的基础上开发应用程序的,并检查了所有的可能性,但什么都没有。谢谢你的帮助。如果这是唯一的可能性,我会接受它:D。
ACTION_SCREEN_ON
ACTION_SCREEN_ON
ACTION_SCREEN_OFF