Android receiver for multiple actions?

前端 未结 4 2066
我在风中等你
我在风中等你 2021-02-19 10:36

Simple question - Can I register a single BroadcastReceiver to multiple Intent actions? Here\'s what I\'m considering:



        
4条回答
  •  遥遥无期
    2021-02-19 11:16

    about the priority you set:

    https://developer.android.com/guide/topics/manifest/intent-filter-element.html

    android:priority The priority that should be given to the parent component with regard to handling intents of the type described by the filter. This attribute has meaning for both activities and broadcast receivers:

    It provides information about how able an activity is to respond to an intent that matches the filter, relative to other activities that could also respond to the intent. When an intent could be handled by multiple activities with different priorities, Android will consider only those with higher priority values as potential targets for the intent.

    It controls the order in which broadcast receivers are executed to receive broadcast messages. Those with higher priority values are called before those with lower values. (The order applies only to synchronous messages; it's ignored for asynchronous messages.)

    Use this attribute only if you really need to impose a specific order in which the broadcasts are received, or want to force Android to prefer one activity over others.

    The value must be an integer, such as "100". Higher numbers have a higher priority. The default value is 0. The value must be greater than -1000 and less than 1000.

提交回复
热议问题