Notification n=new Notification(R.drawable.ic_launcher,"hello world",System.currentTimeMillis());
這是創建一個Notification 的對象,的一個參數是圖標,顯示在頂部,第二個參數是提示的類容,第三個參數是什麼時候提示。
PendingIntent pi=PendingIntent.getActivity(this, 0, new Intent(this,TestActivity.class), PendingIntent.FLAG_UPDATE_CURRENT);
第一個參數是Context的對象,第二個參數還沒有使用,第三個參數是要跳的界面,第四個參數是表示如果該描述的PendingIntent已存在,則改變已存在的PendingIntent的Extra數據為新的PendingIntent的Extra數據。
n.setLatestEventInfo(this, "hello", "world", pi);
這裡的參數不解釋的
NotificationManager nmanger=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
這裡也不解釋
nmanger.notify(0, n);
發送notification消息
作者 張譯成