android之Notification監聽系統清除通知欄

l_serein發表於2012-05-15

Notification notification = new Notification(R.drawable.icon"嘎你妹", System.currentTimeMillis());

NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

Intent ii = new Intent();

PendingIntent contentIntent = PendingIntent.getActivity(context, 0, ii, PendingIntent.FLAG_UPDATE_CURRENT);

notification.flags = Notification.FLAG_AUTO_CANCEL;

notification.defaults = Notification.DEFAULT_SOUND;

 

Intent i = new Intent("com.android.broadcasttest.xxx");//已有廣播

notification.deleteIntent = PendingIntent.getBroadcast(this, 0,i, 0);

notification.setLatestEventInfo(context"嘎嘎訊息",

String.format("共%d條新訊息", 1), contentIntent);

nm.notify(R.string.app_namenotification);

相關文章