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;
        }
}

なぜこれが起こっているのかよくわかりません。何か助けはありますか?

4

3 に答える 3

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());
于 2012-07-01T23:25:20.693 に答える
7

android lollipopで発生した別の問題は、大きなアイコンの横に小さなアイコンが表示されていたことです。それを解決するには、大きなアイコンを設定しないでください。小さいアイコン設定のみを使用してください。

于 2015-02-12T15:48:25.427 に答える
0

http://developer.android.com/guide/topics/manifest/uses-sdk-element.html Androidマニフェストの最大SDKバージョンを19(つまりKitKat)に設定した場合、アプリはlolipop向けの通知を表示しなくなります

于 2016-03-15T15:12:18.393 に答える