I have difficulty in understanding power management best practices and sleep mode state of android device.
Sleep mode.
1.1) when will this happen?
1.2) CPU is going to sleep and my threads are suspend? and when will this happen?
1.3) To prevent CPU sleeping I can use PARTIAL_WAKE wake lock or alarm manager? What the best for battery?
1.4) How prevent shutdown of WiFi and 3G connection in sleep mode programmatically from my app?
P.S Yes, I understand that it is bad for battery lifetime! I try to find best compromise...
I write my instant messenger application. I need have persistent connection to server. How the best way to achieve this? After ~20-30 minute with screen off I lost internet connection but Skype stays online. How they do it?
I know about C2DM framework. But it is unidirectional from server to application. How the best way to use it for me? Server must know that client really connected!