1

I'm making messaging app. I want to push message to specific chatroom by using broadcast. I though uri.

chat://chatroom/{room name} 

And I send a message to room name 7777.

Intent intent = new Intent(ACTION_UPDATE_CHAT); intent.setData(Uri.parse("chat://chatroom/7777")); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); 

And I regestered a broadcastreceiver with intent filter like below.. But I can't receive message.

IntentFilter filter = new IntentFilter(ACTION_UPDATE_CHAT); filter.addDataScheme("chat"); filter.addDataAuthority("chatroom", null); filter.addDataPath("7777", PatternMatcher.PATTERN_LITERAL); LocalBroadcastManager.getInstance(context).registerReceiver(receiver, filter); 

Please Help!! :)


updated. I can receive br when i remove this line.

filter.addDataPath("7777", PatternMatcher.PATTERN_LITERAL); 

But If then..Every chat room receive br..

2 Answers 2

1

When you send broadcast,the intent action is ACTION_UPDATE_DATA,but when you receive broadcast,the intent action is ACTION_UPDATE_CHAT,maybe it's why you can't receive the message.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! For your help. I modified you mentioned. But still It's not working.
1

You should replace

filter.addDataPath("7777", PatternMatcher.PATTERN_LITERAL);

by

filter.addDataPath("/7777", PatternMatcher.PATTERN_LITERAL);

The change is very subtle. All I did was add a "/" before "7777". This will fix it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.