Joke Collection Website - Blessing messages - Briefly describe how to send broadcast messages in android
Briefly describe how to send broadcast messages in android
1. Send broadcast
Intent intent = new Intent(BroadcastAction);
Bundle bundle = new Bundle();
bundle .putString("***", SUCCESS);
bundle.putString("FullPathName", mFullPathName);
intent.putExtras(bundle);
sendBroadcast(intent);
2. Create an internal class MyBroadcastReceiver in Activity to extend BroadcastReceiver and implement the onReceive method in it.
3. Declare a member variable of type MyBroadcastReceiver in Activity and register:
private MyBroadcastReceiver myBroadcastReceiver;
...
myBroadcastReceiver = new MyBroadcastReceiver();
IntentFilter filter = new IntentFilter();
filter.addAction(BroadcastAction);
registerReceiver(receiver, filter) ;
4. Remember to release after use
unregisterReceiver(receiver);
Note: The BroadcastAction in 1 and 2 must be the same Action
- Previous article:How much is the big data salary of Guangdian Express?
- Next article:How does Xiaomi set the message barrage mode?
- Related articles
- What if etc is blacklisted for arrears?
- The mobile phone can't send text messages to the phone.
- Hello, I borrowed 30 thousand yuan from Xiaoman Finance today, but they told me by text first. ...
- Has the Guangxi Laibin epidemic closed the city?
- Disgusting love message interception
- Was Tik Tok's harassment of private messages reported by the other party?
- Why is a website App suddenly reported to be unavailable?
- How can employees comfort the boss when he stops working?
- Can telecom mobile phones recharge Guangtong games?
- Received a short message from Lacarra, and replied 1. what can I do for you?