Android NotificationCompat在2.3中没有显示大图标

时间:2013-01-22 15:57:21

标签: android notifications android-notifications

我正在玩android中的通知,我想知道为什么NotificationCompat不会在Jellybean中显示大图标和姜饼中的数字(参见图片),我认为那是为了那个目的,它是创造?

这是我如何触发通知:

    @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Button btnShow = (Button)findViewById(R.id.btnNotif);

    Intent intent = new Intent(this, NotificationReceiverActivity.class);
    PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);

    notificationManager =  (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);


        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
        .setWhen(System.currentTimeMillis())
        .setContentText("You are near your point of interest.")
        .setContentTitle("Proximity Alert!")
        .setSmallIcon(android.R.drawable.ic_menu_info_details)
        .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.orchide))
        .setAutoCancel(true)
        .setTicker("Proximity Alert!")
        .setNumber(10)
        .setContentIntent(pIntent)
        .setDefaults(Notification.DEFAULT_LIGHTS| Notification.DEFAULT_VIBRATE| Notification.DEFAULT_SOUND);
        /*Create notification with builder*/
         notification=notificationBuilder.build();

        /*sending notification to system.Here we use unique id (when)for making different each notification
         * if we use same id,then first notification replace by the last notification*/
    btnShow.setOnClickListener(new OnClickListener(){

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            notificationManager.notify(1000, notification);
        }

    });



}

Notification in gingerbread

Notification in Jelly bean

1 个答案:

答案 0 :(得分:3)

蜂窝前API级别会忽略大图标。

NotificationCompat.Builder documentation说: ...在不提供扩展通知的平台版本上,依赖于扩展通知的方法无效...

如果查看NotificationCompat.Builder源代码,您会看到大图标用于蜂窝及以上。