Androidで通知バーNotificationコードインスタンスを作成する

840 ワード


/////    :  NotificationManager
		NotificationManager nm = (NotificationManager) 
				getSystemService(Context.NOTIFICATION_SERVICE);

		/////    :  Notification
		Intent intent = new Intent(this, OtherActivity.class);
		//PendingIntent     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;
		
		/////   :     ,               
		nm.notify(0, notification);
		
		//    
		//nm.cancel(0);