Is there any intent fired every second in Android?

2019-02-25 20:48发布

I am looking for some Intent which get broadcasted every second. I looked into android.intent.action.TIME_TICK but this intent get broadcasted every minute. I know AlarmManger/handler/thread can be used for this purpose, but I am inclined to use system broadcasted intent. Please share your thoughts?

2条回答
神经病院院长
2楼-- · 2019-02-25 21:34

This isn't possible. There is no broadcast intent sent every second.

I've posted a full list of broadcast intents here (it's found in the platforms/android-xx/data/broadcast_actions.txt, and none of them cover per-second actions. This is further confirmed in the documentation (searching "second" on the page produces nothing in this context).

You will have to pick one of AlarmManager, Handler, Thread, Timer, or something else in this vein. Some of this topic is covered here, more here, some stuff on a timer here, et cetera...

查看更多
【Aperson】
3楼-- · 2019-02-25 21:54

I do not think so. First because if system would send a broadcast every second it would drain the battery. Second, if many apps were interested in handling the broadcast, that could seriously slow down the system.


Update

There is in fact a Intent fired once a minute, but there is restriction on how you can use it

http://developer.android.com/reference/android/content/Intent.html#ACTION_TIME_TICK

查看更多
登录 后发表回答