Pro Android with Kotlin


Download 5.42 Mb.
Pdf ko'rish
bet53/223
Sana04.11.2023
Hajmi5.42 Mb.
#1746807
1   ...   49   50   51   52   53   54   55   56   ...   223
Bog'liq
@de android telegram Pro Android with Kotlin Developing Modern Mobile

49
CHAPTER 5: Broadcasts
Table 
5-1
 shows some examples.
Besides actions, a category specifier can be used to restrict an intent filter. We have a couple 
of predefined categories listed in Chapter 
3
, but again you can define your own categories. 
Like for actions, for your own categories you should follow the naming convention of 
prepending your app’s package name to your category name. Once during the intent 
matching process a match in the action is found, all the categories that were declared by the 
sender must be present as well in the receiver’s intent filter for the match to further prevail.

Once an action inside an intent filter matches a broadcast and the filter 
also contains a list of categories, only such broadcasts will match the 
filter for which the categories specified by the sender are all contained in 
the receiver’s category list.
Table 5-1. Action Matches
Receiver
Sender
Match
One filter
action = "com.xyz.ACTION1"
action = "com.xyz.ACTION1"
Yes
One filter
action = "com.xyz.ACTION1"
action = "com.xyz.ACTION2"
No
Two filters
action = "com.xyz.ACTION1"
action = "com.xyz.ACTION2"
action = "com.xyz.ACTION1"
Yes
Two filters
action = "com.xyz.ACTION1"
action = "com.xyz.ACTION2"
action = "com.xyz.ACTION3"
No


50
CHAPTER 5: Broadcasts
Table 
5-2
 shows some examples (one filter only; if there are several filters, the matching 
happens on an “or” basis).
Third, a data-and-type specifier allows for filtering data types. Such a specifier is one of the 
following:

type: The MIME type, for example "text/html" or "text/plain"


Download 5.42 Mb.

Do'stlaringiz bilan baham:
1   ...   49   50   51   52   53   54   55   56   ...   223




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling