Broadcast: Second, the global broadcast (1)

Dynamic registration

public  class Main2Activity the extends AppCompatActivity {
     Private Receiver recevier; // define one receiver
     Private the IntentFilter IntentFilter; 

    @Override 
    protected  void the onCreate (the Bundle savedInstanceState) {
         Super .onCreate (savedInstanceState); 
        the setContentView (R.layout.activity_main2);      // initialize look 
        recevier

= new new Receiver (); IntentFilter = new new the IntentFilter ();
    // global broadcast associated (can be associated with a plurality of) intentFilter.addAction (
"android.net.conn.CONNECTIVITY_CHANGE"); // when the network changes, the system will issue a broadcast is a broadcast such android.net.conn.CONNECTIVITY_CHANGE     // registration broadcast
registerReceiver (recevier, IntentFilter); } // here received
class Receiver the extends the BroadcastReceiver { @Override public void the onReceive (the context context, the Intent Intent) { } } }

 

 

 

 

 

 

 

 

 

 

 

 

In "Radio One" which I wrote the class subdivision opened, and writes some of his own experience, I feel too detailed but uncomfortable (who see his mother so old Presbyterian long, but only introduce something of a Hello)

Guess you like

Origin www.cnblogs.com/bug01/p/11246785.html