broadcastreceiver的简单的接受和发送无序广播

创建一个类继承自BroadcastReceiver

public class Notication extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
        System.out.println("haha");
        System.out.println("收到广播"+getResultData()+"===="+intent.getAction());
    }

}

设置receiver


               
               
               
                
  
              

            
                
            
        

配置对应的权限


  

简单的发送一个无序广播

   public void click(View v){
        
        Intent it = new Intent();
        it.setAction("sbsb");
//      it.setData(Uri.parse("XIAOER"));
        sendBroadcast(it);
    }

你可能感兴趣的:(broadcastreceiver的简单的接受和发送无序广播)