I have an android service Running. In this service, i have a BroadcastReceiver which is registred within the intentFilter : filter.addAction(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON);
I make the registration in the onStartCommand() method, and the unregistration into the onDestroy().
When i perform a screen on/off, my receiver recieves well the intents but many times, like this :
01-25 15:38:02.389 1941 1941 D InternetConnectionCheck: ACTION_SCREEN_ON is received 01-25 15:38:02.391 1941 1941 I InternetConnectionCheck: EventsReceiver.onReceive() android.intent.action.SCREEN_ON 01-25 15:38:02.391 1941 1941 D InternetConnectionCheck: ACTION_SCREEN_ON is received 01-25 15:38:02.396 1941 1941 I InternetConnectionCheck: EventsReceiver.onReceive() android.intent.action.SCREEN_ON 01-25 15:38:02.396 1941 1941 D InternetConnectionCheck: ACTION_SCREEN_ON is received 01-25 15:38:02.400 1941 1941 I InternetConnectionCheck: EventsReceiver.onReceive() android.intent.action.SCREEN_ON 01-25 15:38:02.400 1941 1941 D InternetConnectionCheck: ACTION_SCREEN_ON is received 01-25 15:38:02.402 1941 1941 I InternetConnectionCheck: EventsReceiver.onReceive() android.intent.action.SCREEN_ON 01-25 15:38:02.402 1941 1941 D InternetConnectionCheck: ACTION_SCREEN_ON is received 01-25 15:38:02.404 1941 1941 I InternetConnectionCheck: EventsReceiver.onReceive() android.intent.action.SCREEN_ON
For your informations, i have registered the receiver only one time in onStartCommand() as i described above.
Can anyone help me to solve this problem please ?
As a work arround to solve the problem, i am using a counter to check if the intent is received for the first time or not.