Android: detect reason for wakeup - android

My BroadcastReceiver listens for ACTION_SCREEN_ON events and works well. But is there any way for me to discover what or who has been waking up the phone? Was it the power button? Was it the alarm clock? Was it XYZ?

Related

Trigger an event when an alarm sets off in the clock app

I would like to have some kind of a broadcast receiver or anything that would get triggered when an alarm starts ringing through the clock app so that I can send a request to my esp8266-based microcontroller that would turn the lights on. Would this even be possible?

is there a broadcast message when the alarm goes off?

Do we have any kind of broadcast message when alarm goes off in Android? I couldn't find one. When the alarm goes off, I'd like to start my apps.
EDIT: It's the build-in alarm.

Altenative way to detect screen off/on

Is there an alternative way to detect screen on/off in Android?
I'm currently using ACTION_SCREEN_ON and ACTION_SCREEN_ON intents catched with a receiver, but in API 17 it's bugged (in combination with proximity wake lock).

broadcast receiver not working in sleep mode

I want a alarm System in my application, I want to open a dialog activity when alarm is fired,
it's working fine when phone is active, but the broadcast receiver is not working when phone is sleep or standby mode.
I also use wacklock logic in broadcast receiver but it can't work well.
you need to write service for that keep working in when phone is sleep or standby mode here is the link

Replacing ACTION_SCREEN_ON withy ACTION_USER_PRESENT?

I have a long-running service listening for sensor input. To conserve battery power, I've stopped the sampling of the sensors on ACTION_SCREEN_OFF and started it back up again on ACTION_SCREEN_ON.
Often, however, I just turn my phone on for a quick glance at the clock on the lock-screen (to check the current time) and then turn it off again without unlocking the phone. In that case, there's no reason to spin up the sensors just to shut then down again at once.
So therefore I tried replacing ACTION_SCREEN_ON with ACTION_USER_PRESENT in my broadcast listener. This worked fine except for one special case: When the screen goes off and I press the power button (or home button) at once, the lock screen is skipped. And then the ACTION_USER_PRESENT is never received, only the ACTION_SCREEN_ON.
Is there a way for me broadcast receiver, upon receiving an ACTION_SCREEN_ON to know if the screen-lock is active and to expect a ACTION_USER_PRESENT later? Or if the lock-screen is skipped, not to wait upon ACTION_USER_PRESENT and go ahead and restart the sampling at once?
Till Android 4.4, if screen is turned on and lock screen is disabled, only ACTION_SCREEN_ON is fired. From Android 5.0, in this case, both ACTION_SCREEN_ON and ACTION_USER_PRESENT are fired.

Categories

Resources