开发者

How to receive the TIME_TICK intent

开发者 https://www.devze.com 2023-03-31 09:35 出处:网络
This isn\'t a very advanced question, I just don\'t understand how exactly to receive intents in Android. I want to update a clock app (only when it\'s in the foreground) every minute. I guess I have

This isn't a very advanced question, I just don't understand how exactly to receive intents in Android. I want to update a clock app (only when it's in the foreground) every minute. I guess I have to create a class that extends BroadcastReceiver, and implement the method onReceive(Context cont开发者_运维百科ext, Intent intent), and add an intent filter in my AdroidManifest.xml? How do I add that filter? Is that the only thing that makes the intent received ACTION_TIME_TICK?


As Android SDK reference states, you have to explicitly register for this intent with:

Context.registerReceiver().
0

精彩评论

暂无评论...
验证码 换一张
取 消