broadcastreceiver - Android - How to use a local broadcast receiver? -


I am trying to use a local broadcast receiver.

To do this I'll next step -

1) In one activity, I should have something like that, I have created a square -

 < Code> Private Sector NewGroupReceiver BroadcastReceiver Extended {@ Override Public Disclaimer (Reference Reference, Intent of Intent) {Log D. ("Group", "Found in Retrieval"); Toast. Make Text (This, "Working", Toast.LnnGHHRT) Show ();}}  

2) In the same activity, I create a receiver in the next code (Bundled savedinstenstate) {SuperConnect (Saved Instantstate); Newgroup Receiver Receiver = New Newcomer Receiver (); // Intro Filter action = "com.example.demo_service.action.SERVICE_FINISHED" intent filter filter = new intent filter ("com.example.apps.action.NEW_GROUP"); // register receiver: register receiver (receiver, filter);}

3) In a service class, I want to know the next one The code used when something happened -

  intent to result in the result = new intent ("com.example.apps.action.NEW_GROUP"); Local Broadcast Manager Local Broadcast Manager = Local BroDext Manager. Just Instance (this); LocalBroadcastManager.sendBroadcast (resultsIntent);  

The problem now is that when I want to know that this is happening - I think that it has come into the code that I used in step 3, but it is like this Do not seem to enter the broadcast receiver - Step 1 code.

Any ideas what I am doing wrong here? Thanks for any assistance.

You are using LocalBroadcastManager , but you receive the receiver " Global "intent on registering. You must either use the Local Board Manager on the application reference to register the recipient or to broadcast the broadcast:

Step 2

 < Code> LocalBroadcastManager.getInstance (this). Registrar receiver (receiver, filter);  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -