4
Activity has leaked IntentReceiver ScreenReceiver that was originally registered here. Are you missing a call to unregisterReceiver()?

in main activity I have

 // 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();

and when application is closed I get this message.

ACTION_SCREEN_OFF

AND

ACTION_SCREEN_ON 

can not be registered in AndroidManifest but only programatically. What can I do? I don't want to use Service because if service is running all day this is not good for battery. What is the solution? How to use this receivers?

4

1 回答 1

2

您不能从 android manifest 文件中注册这些接收器。它根本不支持。唯一的方法是长时间运行服务并在服务中注册这些接收器。所以如果你真的想使用

ACTION_SCREEN_ON 

ACTION_SCREEN_OFF 

然后你必须使用服务

于 2013-04-16T09:35:01.433 回答