Joke Collection Website - Public benefit messages - Help on how to globally monitor Android broadcasts
Help on how to globally monitor Android broadcasts
This is the code in onCreate
//Register to receive new messages to listen for broadcast
msgReceiver = new NewMessageBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(EMChatManager
.getInstance().getNewMessageBroadcastAction());
intentFilter.setPriority(3);
registerReceiver(msgReceiver, intentFilter );
The following are the operations in the broadcast written by myself
private class NewMessageBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive (Context context, Intent intent) {
//Abort broadcast
abortBroadcast();
//Message id (each message will generate a unique one id, currently generated by SDK)
String msgId = intent.getStringExtra("msgid");
EMMessage message = EMChatManager.getInstance().getMessage(msgId);
String news = ((TextMessageBody) message.getBody()).getMessage();
//Sender id
String userId = intent.getStringExtra("from ");
username = userId;
Info info = new Info();
info.setText(news);
info.setId(msgId);
info.setUserid(userId);
list.add(info);
}
}
- Related articles
- How to choose a mobile phone?
- What is the actual experience of port number transfer?
- Why did the neighborhood Committee urge you to get a booster shot?
- Couple copywriting in different places
- Pluralistic plot of purity and love
- How to set the love between light and night? How to set the birthday of light and night?
- Is it true that Shenzhen University calls to recruit students?
- The teacher cheated on the content of the text message
- How to restore the original data after the phone is swiped?
- Encourage new people.