Joke Collection Website - Blessing messages - When android accepts the broadcast, how do you determine which application sent the broadcast?
When android accepts the broadcast, how do you determine which application sent the broadcast?
View the interface that receives the broadcast:
Public abstract void onReceive (Context, intention);
There is a parameter context here, which is the context of the application that sends the broadcast, and the general application sends the broadcast in a way similar to the following:
Context context = MyActivity.this
Context.sendBroadcast (intention);
The context in the received broadcast is the context when it was sent here. By printing the context in onReceive, you can clearly know which application sent the broadcast:
Public void on Receive {
Log.w (tag, "context =“+context););
//。 . . . . .
}
- Related articles
- Connotation and characteristics of green marketing
- How to cancel the SMS service of China Construction Bank?
- The warm reminder of traveling in rainy and snowy days is very short.
- 5 173 Buy a CF account.
- Can you call 10086 to find out the reason for the yellow code?
- How to say birthday greetings in English?
- How to turn on the short message reading function?
- How much is the "SMS receipt"?
- How to greet friends who haven't been in touch for a long time?
- What is Unicom's Wotong?