android 本地通知

來源:互聯網
上載者:User

標籤:uil   manage   perm   tle   set   動效   cat   draw   設定   

 NotificationManager manager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);                NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(Demo10Activity.this);                mBuilder.setContentTitle("測試標題")//設定通知欄標題                        .setContentText("測試內容")                        .setTicker("測試通知來啦") //通知首次出現在通知欄,帶上升動畫效果的                        .setWhen(System.currentTimeMillis())//通知產生的時間,會在通知資訊裡顯示,一般是系統擷取到的時間                        .setPriority(Notification.PRIORITY_DEFAULT) //設定該通知優先順序//  .setAutoCancel(true)//設定這個標誌當使用者單擊面板就可以讓通知將自動取消                        .setOngoing(false)//ture,設定他為一個進行中的通知。他們通常是用來表示一個背景工作,使用者積极參与(如播放音樂)或以某種方式正在等待,因此佔用裝置(如一個檔案下載,同步操作,主動網路連接)                        .setDefaults(Notification.DEFAULT_VIBRATE)//向通知添加聲音、閃燈和震動效果的最簡單、最一致的方式是使用當前的使用者預設設定,使用defaults屬性,可以組合                        //Notification.DEFAULT_ALL  Notification.DEFAULT_SOUND 添加聲音 // requires VIBRATE permission                        .setSmallIcon(R.drawable.ic_launcher);//設定通知小ICON                Intent intent = new Intent(Demo10Activity.this,Demo9Activity.class);                PendingIntent pendingIntent = PendingIntent.getActivity(Demo10Activity.this, 0, intent, 0);                mBuilder.setContentIntent(pendingIntent);                Notification notification = mBuilder.build();                notification.flags = Notification.FLAG_AUTO_CANCEL;                manager.notify(1,notification);

 

android 本地通知

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.