0

I'm a newbie when it comes to Android programming, but I've been doing a bit of digging in the SDK. I'm trying to create an application which allows me to wake the phone via a message sent over the network.

Ideally, I will have a java program on my computer which has a button I can push to wake the droid. I've read that a 3g socket can do this, but given that most providers use NAT, this doesn't seem like a good route.

I'd like to stay away from leaving the phone running with a wakelock, since that seems like it would kill the battery life. Is there any way to have the droid wake on an incoming network event? If not, what do you think the best way would be to approach this problem?

DIF
  • 2,470
  • 6
  • 35
  • 49
Maxthecat
  • 1,250
  • 17
  • 37

2 Answers2

1

You can utilize C2DM messaging as well. You can initiate a wakelock when the C2DM message is received, do what you need and then release the lock.

C2DM Documentation

MattC
  • 12,285
  • 10
  • 54
  • 78
  • This is nifty, didn't know about it. The OP would need to set up his own third-party server for this though, correct? – koopaking3 Mar 06 '12 at 00:05
  • C2DM may not be reliable, though. I don't have any personal experience with it. I do know that Google states `C2DM makes no guarantees about delivery or the order of messages.` – Reed Mar 06 '12 at 01:43
  • I use it and it's pretty reliable. It's what Google uses to talk with devices for their own services. Nothing is going to be 100% reliable because mobile network connectivity is so chaotic. – MattC Mar 06 '12 at 15:10
  • @koopaking3 Yes, he'd need a server to initiate the C2DM message to the device. Obviously what he does once he receives the C2DM is up to him. – MattC Mar 06 '12 at 15:12
0

The only way that I can think of would be to create a BroadcastReceiver and register it for SMS_RECIEVED than send the device an SMS with some unique identifier of your choosing. The BroadcastReceiver will read incoming SMS and if it finds the unique identifier then it will wake lock the device and do any work (this you can handle in a Service). If you want to actually wake the device screen, that is a well-covered topic, but here is one post on it. Once you've accomplished your work, you could then delete the SMS if you don't want it cluttering the inbox. Note that you would need the READ_SMS and RECEIVE_SMS permissions in your Manifest.

Sadly this isn't as elegant as a cool Wake on LAN type feature, but it should work nonetheless.

Let me know if you need an clarifying or examples.

Community
  • 1
  • 1
koopaking3
  • 3,375
  • 2
  • 25
  • 36