后台推送心跳包应该怎么做?尝试了2天,最好的成绩是通过
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime()+t,
pendingIntent);
正常工作了1个小时,然后就被系统把每分钟一个的延时改成了15分钟一次...
实在是想不出来好办法了...
后台推送心跳包应该怎么做?尝试了2天,最好的成绩是通过
manager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime()+t,
pendingIntent);
正常工作了1个小时,然后就被系统把每分钟一个的延时改成了15分钟一次...
实在是想不出来好办法了...
|
zgxltxzMar 12, 2015
1
If your application has strong ordering requirements there are other APIs that you can use to get the necessary behavior; see setWindow(int, long, long, PendingIntent) and setExact(int, long, PendingIntent).
https://developer.android.com/reference/android/app/AlarmManager.html#set(int |
|
4
@zgxltxz android alarmmanager WAKEUP 是我知道的的唯一一个可以在CPU关闭后还能唤醒手机执行程序的方式。
除此之外就只有持有唤醒锁强制 CPU 不关闭了。 另一个待机唤醒的方式是网络数据到达,也会唤醒 CPU 处理,这需要由服务端发起,但是如果由于意外状况导致长连接断开,这个唤醒方式会失效。 |