廣播機制java
<receiver android:name=".BootCompleteReceiver" > <intent-filter> <action android:name="android.intent.action.BOOT_COMPLETED" /> </intent-filter> </receiver>
Intent intent = new Intent("com.example.broadcasttest.MY_BROADCAST"); sendBroadcast(intent);
//sendBroadcast(); sendOrderedBroadcast(intent, null);
<!-- 範圍是 -1000 ~ 1000 --> <intent-filter android:priority="100" >
* 可設置截斷
@Override public void onReceive(Context context, Intent intent) { //廣播截斷,後面的廣播接收器將沒法再接收到這條廣播 abortBroadcast(); }
//sendBroadcast(intent); localBroadcastManager.sendBroadcast(intent); // 發送本地廣播