欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

android實現(xiàn)狀態(tài)欄添加圖標的函數(shù)實例

 更新時間:2015年10月08日 12:48:40   作者:pgalxx  
這篇文章主要介紹了android實現(xiàn)狀態(tài)欄添加圖標的函數(shù),較為詳細的分析了Android狀態(tài)欄添加及刪除圖標的具體實現(xiàn)技巧,具有一定參考借鑒價值,需要的朋友可以參考下

本文實例講述了android實現(xiàn)狀態(tài)欄添加圖標的函數(shù)。分享給大家供大家參考。具體如下:

private void showNotification() { 
 // 創(chuàng)建一個NotificationManager的引用 
 NotificationManager notificationManager = (NotificationManager) 
  AutoFile.this.getSystemService(android.content.Context.NOTIFICATION_SERVICE); 
 // 定義Notification的各種屬性 
 Notification notification = new Notification(R.drawable.dvd, 
  "天籟之音播放器", System.currentTimeMillis()); 
 notification.flags |= Notification.FLAG_ONGOING_EVENT; // 將此通知放到通知欄的"Ongoing"即"正在運行"組中 
 notification.flags |= Notification.FLAG_NO_CLEAR; // 表明在點擊了通知欄中的"清除通知"后,此通知不清除,經(jīng)常與FLAG_ONGOING_EVENT一起使用 
 notification.flags |= Notification.FLAG_SHOW_LIGHTS; 
 notification.defaults = Notification.DEFAULT_LIGHTS; 
 notification.ledARGB = Color.BLUE; 
 notification.ledOnMS = 5000; 
 // 設置通知的事件消息 
 CharSequence contentTitle = "天籟之音正在播放……"; // 通知欄標題 
 CharSequence contentText = "ameyume"; // 通知欄內(nèi)容 
 Intent notificationIntent = new Intent(AutoFile.this, MyPlayerService.class); // 點擊該通知后要跳轉(zhuǎn)的Activity 
 PendingIntent contentItent = PendingIntent.getActivity(AutoFile.this, 0, 
  notificationIntent, 0); 
 notification.setLatestEventInfo(AutoFile.this, contentTitle, contentText, 
  contentItent); 
 // 把Notification傳遞給NotificationManager 
 notificationManager.notify(0, notification); 
} 

要刪除圖標,用以下代碼:

// 啟動后刪除之前我們定義的通知 
NotificationManager notificationManager = (NotificationManager) this 
 .getSystemService(NOTIFICATION_SERVICE); 
notificationManager.cancel(0);

希望本文所述對大家的Android程序設計有所幫助。

相關(guān)文章

  • Android ListView仿微信聊天界面

    Android ListView仿微信聊天界面

    這篇文章主要為大家詳細介紹了ListView仿微信聊天界面,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2021-06-06
  • Android仿微信加號菜單模式

    Android仿微信加號菜單模式

    這篇文章主要為大家詳細介紹了Android仿微信加號菜單模式的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2018-04-04
  • Android自定義gridView仿頭條頻道拖動管理功能

    Android自定義gridView仿頭條頻道拖動管理功能

    這篇文章主要介紹了Android自定義gridView仿頭條頻道拖動管理功能,本文通過實例代碼效果圖展示給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2019-12-12
  • Android學習教程之分類側(cè)滑菜單(5)

    Android學習教程之分類側(cè)滑菜單(5)

    這篇文章主要為大家詳細介紹了Android學習教程之分類側(cè)滑菜單的具體代碼,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-11-11
  • Android編程實現(xiàn)TextView部分顏色變動的方法

    Android編程實現(xiàn)TextView部分顏色變動的方法

    這篇文章主要介紹了Android編程實現(xiàn)TextView部分顏色變動的方法,涉及Android針對TextView樣式操作的相關(guān)技巧,具有一定參考借鑒價值,需要的朋友可以參考下
    2015-11-11
  • Android中BaseActivity自定義標題欄

    Android中BaseActivity自定義標題欄

    這篇文章主要介紹了Android中BaseActivity自定義標題欄,非常實用,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • 淺析AndroidStudio3.0最新 Android Profiler分析器(cpu memory network 分析器)

    淺析AndroidStudio3.0最新 Android Profiler分析器(cpu memory network

    Android Profiler分為三大模塊: cpu、內(nèi)存 、網(wǎng)絡。本文給大家介紹AndroidStudio3.0最新 Android Profiler分析器(cpu memory network 分析器)的相關(guān)知識,他們的基本使用方法,在文中都給大家提到,具體內(nèi)容詳情大家通過本文一起學習吧
    2017-12-12
  • Android軟鍵盤彈出時的界面控制方法

    Android軟鍵盤彈出時的界面控制方法

    這篇文章主要介紹了Android軟鍵盤彈出時的界面控制方法,結(jié)合實例形式分析了Android軟鍵盤彈出后的三種模式,涉及Android針對AndroidManifet.xml的修改技巧,需要的朋友可以參考下
    2016-08-08
  • Android ViewDragHelper仿淘寶拖動加載效果

    Android ViewDragHelper仿淘寶拖動加載效果

    這篇文章主要為大家詳細介紹了Android ViewDragHelper仿淘寶拖動加載效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • Android最新版本開發(fā)環(huán)境搭建圖文教程

    Android最新版本開發(fā)環(huán)境搭建圖文教程

    這篇文章主要為大家詳細介紹了Android最新版本開發(fā)環(huán)境搭建圖文教程,重點在于配置JDK,以及adt-bundle,感興趣的小伙伴們可以參考一下
    2016-07-07

最新評論