2012-06-26 2 views
2

초기 시세 텍스트를 표시하지 않고 진행중인 알림을 표시하려고합니다. 내가 생성자에서 null로 시세 텍스트를 설정하여이 이전 스타일의 알림 작업을 얻을 수 있었다 그러나Notification.Builder를 사용하여 알림에서 티커 텍스트를 숨기기

mNotification = new Notification(R.drawable.ic_stat_playing, null, System.currentTimeMillis()); 

, 나는 눈치가이 방법은 현재 사용되지 않은 통지하고, Notification.Builder의 사용을 인스턴스화 대신 권장합니다. 이 새로운 Notification.Builder으로 시세 표시를 해제 만 가능하지

Notification.Builder builder = new Notification.Builder(this); 

CharSequence contentText = "contentText here"; 

Intent launchIntent = new Intent(this, MainActivity.class); 

// The PendingIntent to launch our activity if the user selects this 
// notification 
PendingIntent contentIntent = PendingIntent.getActivity(this, -1, 
       launchIntent, PendingIntent.FLAG_UPDATE_CURRENT); 

builder.setContentIntent(contentIntent) 
    .setSmallIcon(R.drawable.ic_stat_playing) 
    .setLargeIcon(null) 
    .setTicker(null) 
    .setOnlyAlertOnce(true)     
    .setWhen(System.currentTimeMillis()) 
    .setContentTitle(contentTitle) 
    .setOngoing(true) 
    .setContentText(contentText); 

mNotification = builder.getNotification(); 

startForeground(NOTIFICATION_ID, mNotification); 

입니다 : 내가 null로 시세 텍스트를 설정할 때, 난, 시세 텍스트없이 표시 지금 알림을받을 수없는 이유는 무엇입니까? 그렇기 때문에 사용되지 않는 코드를 업데이트 할 수 없으므로 불행합니다.

편집 - 마지막으로 일했다 코드 :

mNotification = builder.getNotification(); 

mNotification.tickerView = null; 

startForeground(NOTIFICATION_ID, mNotification); 
+0

이것은 올바른 방법입니다 (즉,'setTicker (null)'). 위의 코드는 어떻게됩니까? 어쨌든 티커가 나타 납니까? 어떤 OS, 장치 등? – dsandler

+0

응답 해 주셔서 감사합니다. 예, 위의 코드로 어쨌든 시세표가 표시됩니다. 나는 안드로이드 4.0.3을 실행하는 Asus Transformer TF101 타블렛과 안드로이드 3.2를 실행하는 10.1 인치 갤럭시 탭에서 이것을 테스트하고있다. – inky

답변

2

시도 빌더 후 null. 그게 내게 잘 작동 코드처럼 :

Notification notif = builder.build(); 
notif.tickerView = null; 
mNotificationManager.notify(id, notif); 
+0

고마워, 마침내 해결해 줬어! – inky

+0

고마워, 나는 똑같은 행동을 했어. – Jagoliveira

3

당신은 모든 .setTicker을 포함 할 필요가 없습니다, 너무처럼 생략 :에 tickerView을 설정하는

builder.setContentIntent(contentIntent) 
.setSmallIcon(R.drawable.ic_stat_playing) 
.setLargeIcon(null) 
.setOnlyAlertOnce(true)     
.setWhen(System.currentTimeMillis()) 
.setContentTitle(contentTitle) 
.setOngoing(true) 
.setContentText(contentText); 
+1

나는 그것을 시험해 보았다. 그러나 그것은 나에게 어떤 차이도 만들지 않았다. – inky

관련 문제