6

응용 프로그램의 알림 표시 줄에 티커의 작은 아이콘 만 표시됩니다. 그러나 "그늘"을 아래로 내리면 시크릿의 작은 아이콘과 Notification.Builder에서 설정 한 큰 아이콘이 모두 표시됩니다. 내 코드는 다음과 같습니다.알림 표시 줄에 큰 아이콘과 작은 아이콘이 모두 표시됩니다.

if (Build.VERSION.SDK_INT > 10){ 
      notification = new Notification(R.drawable.ic_stat_mintchip, 
        "This is a test", 
        System.currentTimeMillis()); 
      notification.largeIcon = (((BitmapDrawable)c.getResources().getDrawable(R.drawable.ic_launcher)).getBitmap()); 
      notification.defaults |= Notification.DEFAULT_ALL; 
      notification.number += 1; 
      notification.flags |= Notification.FLAG_AUTO_CANCEL; 

     } else { 
      notification = new Notification(R.drawable.ic_stat_mintchip, 
        "This is a test", 
        System.currentTimeMillis()); 

       notification.flags |= Notification.FLAG_AUTO_CANCEL; 
       notification.defaults |= Notification.DEFAULT_ALL; 
       notification.number += 1; 
     } 
} 

나는 왜 이런 일이 발생하는지 잘 모릅니다. 어떤 도움이 필요합니까?

+1

의미 것 (19) (즉 킷캣) 앱을 안드로이드 매니페스트에 최대 SDK 버전을 설정 한 경우? – CommonsWare

+0

예, 1 초 ... http://imgur.com/07lxg – D4N14L

+1

나는 당신이 민트 칩이라고 생각합니다. 나는 왜 당신이 그 효과를 얻고 있는지 확실히 확신하지 못합니다. 어떤 장치입니까? 당신의 질문이 당신이'Notification.Builder'를 사용하고 있다고 말하는 반면, 당신의 코드는 그렇지 않습니다. 안드로이드 지원 프로젝트의'NotificationCompat.Builder' 사용을 고려해 볼 수 있습니다. – CommonsWare

답변

11

여기서 문제는 아마도 Notificaiton.Builder 클래스를 사용하지 않는다고 생각합니다. 내가 안드로이드 롤리팝에 있었다 또 다른 문제가 있다는 것입니다

Notification.Builder nb = new Notification.Builder(context) 
    .setContentTitle("title") 
    .setContentText("content") 
    .setAutoCancel(true) 
    .setLargeIcon(largeIcon) 
    .setSmallIcon(R.drawable.small_icon) 
    .setTicker(s.getText()); 
NotificationManager nm = (NotificationManager)context.getSystemService(Context.NOTIFICATION_SERVICE); 
nm.notify(100, nb.build()); 
+0

완벽하게 작업했습니다. – D4N14L

+1

Android4.04에서 'nb.build()'를 컴파일 할 수 없으며 대신 nb.getNotification()을 사용합니다. – herbertD

+0

티커 텍스트를 사용하는 경우 어떤 아이콘이 사용됩니까? 그리고 그것을 어떻게 커스터마이징하고 그것을 위해 다른 하나를 사용할 수 있고 통지 자체에 대해 다른 것을 사용할 수 있습니까? –

7

을 : 여기에 당신이 무엇을 할 수 있는지의 작은 예 (당신이 비록 자신의 변수를 삽입해야하고, 당신이 진동으로 사용되는 다른 속성을 설정하는 것)는이다 작은 아이콘이 큰 아이콘 옆에 표시되었습니다. 이를 해결하려면 큰 아이콘을 설정하지 마십시오! 작은 아이콘 설정 만 사용하십시오.

+1

하지만 둘 다 사용하고 싶습니다. 그걸 할 방법이 있니? – vedant1811

+0

두 아이콘을 모두 설정하면 두 아이콘이 모두 나타납니다. – ravyoli

+3

작은 아이콘을 숨기는 방법은 http://stackoverflow.com/a/33943309/218473을 참조하십시오. – Maragues