Cost of raising an Intent in android

前端 未结 2 1551
别那么骄傲
别那么骄傲 2021-02-18 22:19

How much performance does it costs to broadcast intents? Is it okay to broadcast multiple per second or are intents expensive?

2条回答
  •  独厮守ぢ
    2021-02-18 22:31

    It doesn't cost THAT much, but think of it the same way as you would a broadcast in a network environment. If you want to continually send a message to a device, you wouldn't send broadcasts every 100ms. That would just flood the network. Sending a broadcast once every, say, 10 seconds might be appropriate though.

    What exactly the best implementation is entirely depends on what you're doing. In certain circumstances, if you have several services running that need to be run independently, and you're only broadcasting these intents that fast for say, 10 or 15 seconds. That might be ok.

    But we can't really say.

提交回复
热议问题