Android 的 BroadcastReceiver
http://developer.android.com/reference/android/content/BroadcastReceiver.html
BroadcastReceiver 分為一般廣播和有序廣播
有序廣播中設定 priority ,值 越大,級別越高, 假如 設定的數為3 ,2,1,那麼 3 接收不到或不接收 ,2和1也就接收不到
有序廣播
<receiver android:name=".one">
<intent-filter android:priority="1">
<action android:name="abc"/>
</intent-filter>
</receiver>
<receiver android:name=".three">
<intent-filter android:priority="3">
<action android:name="abc"/>
</intent-filter>
</receiver>
<receiver android:name=".two">
<intent-filter android:priority="2">
<action android:name="abc"/>
</intent-filter>
</receiver>
無序廣播的接收者不能確定誰先接收到
無須廣播的部分程式碼:
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
String name = intent.getStringExtra("name");
// Toast.makeText(context, "Hello !--->++"+name, 1).show();
manger = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder builder =new NotificationCompat.Builder(context);
builder .setContentTitle("流量馬上就 Over 了");
builder.setTicker("廣播來啦");
builder.setContentText("你要掉網啦 "+name);
builder.setSmallIcon(R.drawable.ic_launcher);
manger.notify(1001,builder.build());
}
public broadcastReceiver() {
// TODO Auto-generated constructor stub
}
相關文章
- Android之BroadcastReceiverAndroidAST
- Android BroadcastReceiver(廣播)AndroidAST
- Android - BroadcastReceiver 廣播AndroidAST
- Android BroadcastReceiver使用詳解AndroidAST
- 【Android原始碼】BroadcastReceiver的工作過程Android原始碼AST
- Android的IPC機制(六)—— BroadcastReceiver的使用AndroidAST
- Android Service 服務(二)—— BroadcastReceiverAndroidAST
- Android的BroadcastReceiver和EventBus區別是什麼AndroidAST
- Android 四大元件之 BroadcastReceiverAndroid元件AST
- Android四大元件之BroadcastReceiverAndroid元件AST
- Android知識點複習3(BroadcastReceiver)AndroidAST
- Android 四大元件之“ BroadcastReceiver ”Android元件AST
- Android 8.0 原始碼分析 (六) BroadcastReceiver 啟動Android原始碼AST
- Android四大元件之BroadcastReceiver篇Android元件AST
- android學習筆記之Intent與BroadcastReceiverAndroid筆記IntentAST
- Android四大元件之——BroadcastReceiver介紹Android元件AST
- Android點將臺:傳令官[-BroadcastReceiver-](使用級)AndroidAST
- Android學習之四大元件(四)——BroadcastReceiverAndroid元件AST
- 幾種常用BroadcastReceiverAST
- Android探索之BroadcastReceiver具體使用以及安全性探究AndroidAST
- Android應用例項之----基於BroadCastReceiver的SD卡裝載解除安裝例項!AndroidASTSD卡
- 使用廣播-BroadcastReceiver最詳細解析AST
- 安卓開發之廣播接收器BroadcastReceiver安卓AST
- 通過BroadcastReceiver實現監聽電池電量AST
- 3-AII–BroadcastReceiver實現鎖、開屏、簡訊監聽AIAST
- 用廣播 BroadcastReceiver 更新 UI 介面真的好嗎?全方位解析廣播ASTUI
- 14天學會安卓開發(第九天)ContentProvider與BroadcastReceiver安卓IDEAST
- Android 面試(五):探索 Android 的 HandlerAndroid面試
- 【Android】神奇的android:clipChildren屬性Android
- [android]android-am命令的使用Android
- Android的ListViewAndroidView
- android NDK的android.mk檔案的詳解Android
- Android進階(七)Android中的ClassLoaderAndroid
- Android的儲存----重新認識Android(9)Android
- Android的SQLite----重新認識Android(10)AndroidSQLite
- Android — Android Studio 中常用的快捷鍵Android
- 【Android】Android的快速開發框架AfinalAndroid框架
- 7款Android開發者常用的Android UI元件AndroidUI元件