问题
I'm working on legacy VOIP application on Android. It doesn't use Google Cloud Messaging technology right now, but just keeping its own TCP connection forever.
Recently Google has introduced its Android M preview release with Doze mode
So the question: is there any workaround how the app can receive incoming calls/messages in Doze mode without redesigning the whole system to use GCM?
回答1:
You may use ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS to ask the user permission to be ignored by battery optimization. However, double check Optimizing for Doze and App Standby, it seems to be allowed only for enterprise VoIP/IM (see questions #33114063 and #31154128)
回答2:
No, GCM seems to be the only way. See a great analysis of the problems with doze mode including network and GCM here: https://commonsware.com/blog/2015/06/03/random-musing-m-developer-preview-ugly-part-one.html
来源:https://stackoverflow.com/questions/31604093/android-voip-applications-behavior-in-doze-mode