I'm building an App which does some communications with a server using GCM. It works all fine but one. I've implemented an instant chat which sends notifications to the other android device that there is a new message. If the other device clicks on the noti, it will enter the instant chat room to reply, or just see newly updated messages.
I'm doing this by comparing a flag from the server ; if the message is the first one to send and the app or device is sleeping, it will make a noti which can link to the new chat room. If the message is from the currently running chat room, it will just update it.
But as you can easily see, it can't do anything if the device receiving the message is not awake.
So I want to tell if the device state is awake of not to decide whether the message is from a new chat room, or from a current one. If it's from a new one(when the device is sleeping), it will display a noti which will lead to the newly made chat room, and if it's from the current chat room, it will just update the chat log.