亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

android中創(chuàng)建通知欄Notification代碼實(shí)例

 更新時(shí)間:2015年05月20日 09:50:32   投稿:junjie  
這篇文章主要介紹了android中創(chuàng)建通知欄Notification代碼實(shí)例,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下
///// 第一步:獲取NotificationManager
		NotificationManager nm = (NotificationManager) 
				getSystemService(Context.NOTIFICATION_SERVICE);

		///// 第二步:定義Notification
		Intent intent = new Intent(this, OtherActivity.class);
		//PendingIntent是待執(zhí)行的Intent
		PendingIntent pi = PendingIntent.getActivity(this, 0, intent,
				PendingIntent.FLAG_CANCEL_CURRENT);
		Notification notification = new Notification.Builder(this)
				.setContentTitle("title")
				.setContentText("text")
				.setSmallIcon(R.drawable.ic_launcher).setContentIntent(pi)
				.build();
		notification.flags = Notification.FLAG_NO_CLEAR;
		
		/////第三步:啟動(dòng)通知欄,第一個(gè)參數(shù)是一個(gè)通知的唯一標(biāo)識(shí)
		nm.notify(0, notification);
		
		//關(guān)閉通知
		//nm.cancel(0);

相關(guān)文章

最新評(píng)論