Android通知之狀態列通知
狀態列通知:
//狀態列通知
public void stateBar(View view){
//1.得到通知管理器
NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//2.構建通知
Notification notification = new Notification(android.R.drawable.star_big_off, "這是top資訊", System.currentTimeMillis());
//3.設定通知的點選事件,可以 開啟Activity[PendingIntent.getActivity] 開啟服務[PendingIntent.getService] 傳送廣播[PendingIntent.getBroadcast]
Intent intent = new Intent();
intent.setAction(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:110"));
/**
* 引數一:上下文環境
* 引數二:請求碼(隨意)
* 引數三:由於這裡是開啟Activity,所以引數三就是意圖
* 引數四:標誌位(寫0即可)
*/
PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 100, intent, 0);
//步驟三,上面設定的都是步驟三的引數
notification.setLatestEventInfo(getApplicationContext(), "通知標題", "通知內容", contentIntent );
notification.flags = Notification.FLAG_AUTO_CANCEL;//將通知從上拉下來點選後,從上拉下來的這個地方就不顯示通知了(點選後自動取消)
notification.sound = Uri.parse("/mnt/sdcard/jiaodizhu.mp3");//設定收到通知後的聲音
//4.傳送通知
manager.notify(id++,notification);//第一個引數讓他改變的話,就可以在最上邊這一欄有多個通知,否則同一種的只顯示一個
}
將通知欄拉下來,如果希望點選通知後自動清除通知欄裡的通知就設定notification.flags = Notification.FLAG_AUTO_CANCEL;
相關文章
- 【Android】狀態列通知Notification、NotificationManager詳解(轉載)Android
- kali linux如何開啟電源狀態通知Linux
- Android 狀態列透明Android
- Android常駐通知欄Android
- Android 通知許可權Android
- Android 8 通知渠道(Notification Channels)Android
- [轉]Android 通知Notification 詳解Android
- Android 通知欄顯示自定義通知時設定更高的高度Android
- Android獲取狀態列高度Android
- react-native android狀態列ReactAndroid
- Android全屏與透明狀態列Android
- 通知
- Android 隱藏系統狀態列Android
- PyQt5 之狀態列QT
- 搭建直播平臺,Android開發之禁止下拉通知欄的方法Android
- Android 沉浸式狀態列的實現Android
- android判斷狀態列是否可見Android
- 支付系統之非同步通知非同步
- React Native Modal元件 Android覆蓋狀態列React Native元件Android
- Android-沉浸式狀態列的實現Android
- Java併發之等待/通知機制Java
- Google 將於年底關閉 Android 附近通知功能GoAndroid
- feed留,單聊群聊,系統通知,狀態同步,到底是推還是拉?
- 狀態列
- Android 7.0 SystemUI 之啟動和狀態列和導航欄簡介AndroidSystemUI
- 特別通知
- 遷移通知
- 關於 Android 狀態列的適配總結Android
- iOS奇思妙想之使用block替代通知iOSBloC
- 多執行緒之等待通知機制執行緒
- win10關閉工作列通知方法_怎麼關閉win10訊息通知圖示Win10
- 深入原始碼學習 Android data binding 之:回撥通知管理器 CallbackRegistry 解析原始碼Android
- iOS 12 通知新特性 —— 自定義 App 通知的外觀iOSAPP
- 應用文 | 通知
- iOS 通知中心(NSNotificationCenter)iOS
- iOS 遠端通知iOS
- Laravel——訊息通知Laravel
- nagios mail告警通知iOSAI
- Laravel 訊息通知Laravel