Cost of raising an Intent in android

前端 未结 2 1544
别那么骄傲
别那么骄傲 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:20

    Intents are meant to launch different activities within the Android OS or to inform about basic actions. It seems like a bad design pattern to use them otherwise. As they travel between different processes and therefore implement the Parcelable interface, they are not the most light-weight.

    If you are looking to update different activities at the same time you might consider using a common service.

    According to this blog post, intents are 10 times slower than direct function calls http://andytsui.wordpress.com/2010/09/14/android-intent-performance/

提交回复
热议问题