所以我有一个我正在处理的应用程序。此应用程序需要保持活动状态,以便向服务器发送保持活动消息。
如果我不使用唤醒锁定或wifi锁定应用程序约20分钟左右后无法发送ping消息。
WifiManager.WifiLock
Allows an application to keep the Wi-Fi radio awake. Normally the Wi-Fi radio may turn off when the user has not used the device in a while. Acquiring a WifiLock will keep the radio on until the lock is released. Multiple applications may hold WifiLocks, and the radio will only be allowed to turn off when no WifiLocks are held in any application.
因为如果我使用唤醒锁定,电池会快速耗尽。
我也不想使用GCM,因为它无法保证。
你能给我一个建议吗?