Reputation: 1328
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?
Upvotes: 0
Views: 316
Reputation: 3433
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.
Upvotes: 0
Reputation: 12327
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.
Upvotes: 1