Reputation: 4630
As stated in the answer to a previous question, the CDMA and GSM radios are kept on, even after the CPU is put to sleep on an Android device. My questions are...
Upvotes: 1
Views: 3176
Reputation: 2778
Data cannot be received when the CPU is asleep.
The CPU needs to be woken up once in a while to see if there is new data. In your code to check for the new data, if there is new data, you can stay awake and go off and do your processing.
You definitely want to learn about BroadcastReceiver and android alarms. Basically, you can tell Android to send you an Alarm every 5 minutes or whatever, even if it is sleeping. Your BroadcastReceiver wakes up the CPU when it gets the alarm from android, and stays awake long enough to check if you have new data, or whatever you are trying to do. If you have new data, you can then tell the CPU to stay awake and you can go off and process your new data.
Here is a reasonable tutorial. And of course the Android Developer docs are helpful.
Upvotes: 1
Reputation: 1621
You might want to look into sending push notifications to your device (if you don't specifically need TCP).
Check out the (free) Android Cloud to Device Messaging (C2DM) service from Google (http://code.google.com/android/c2dm/).
It takes a little work to get set up, and is only supported on 2.2+, but really simplifies the client/server architecture.
Upvotes: 1