2013-04-21 3 views
1

이 내 코드입니다 :방법으로 알림을받을 알림으로 진행하지

Notification n = new Notification(); 
n.icon = R.drawable.ic_launcher; 
n.tickerText="test"; 
n.defaults |= Notification.DEFAULT_ALL; 

Intent dummyIntent = new Intent(); 
dummyIntent.setAction("dummy"); 
PendingIntent pi = PendingIntent.getBroadcast(c, 0, dummyIntent, 0); 
n.setLatestEventInfo(c, "test","test", pi); 

NotificationManager nm = (NotificationManager)c.getSystemService(Context.NOTIFICATION_SERVICE); 
    nm.notify(1, n); 

나뿐만 진행하지 알림으로이 넣어합니다. 그러나이 알림은 onGoing으로 표시됩니까? 왜?

답변

2

이 방법으로 알림을 만들 수 있습니다. 이것은 알림을 만드는 새로운 방법이며 herehere과 같이 이전 알림보다 더 잘 사용자 지정할 수 있습니다.

NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); 
notificationBuilder = new NotificationCompat.Builder(mContext); 
notificationBuilder.setContentTitle("Title") 
          .setContentText("Text") 
          .setSmallIcon(R.drawable.icon) 
          .setContentIntent(contentIntent) 
          .setOngoing(false) 
          .setTicker("Ticker Text"); 

setOngoing()하면 true 또는 false으로 설정할 수 있습니다.

관련 문제