public class MReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { //ToDo } }
<receiver android:name=".MReceiver" android:exported="true"> <intent-filter android:priority="100"> <action android:name="com.example.AndroidTest_01.receiver1"></action> </intent-filter> </receiver>
Intent intent1=new Intent(MyActivity.this,MReceiver.class); sendBroadcast(intent1);
Intent intent1=new Intent(); intent1.setAction("com.example.AndroidTest_01.receiver1"); sendBroadcast(intent1);
sendBroadcast(intent1);
sendOrderedBroadcast(intent1,null);
@Override public void onReceive(Context context, Intent intent) { //ToDo abortBroadcast(); }
registerReceiver(new MReceiver(),new IntentFilter("com.example.AndroidTest_01.receiver1"));
MReceiver receiver=new MReceiver(); unregisterReceiver(receiver);
LocalBroadcastManager localBroadcastManager=LocalBroadcastManager.getInstance(MyActivity.this); localBroadcastManager.sendBroadcast(new Intent("com.example.AndroidTest_01.receiver1"));