0

通知を表示するには、次の方法があります。

private void sendNotification(String msg) {
        mNotificationManager = (NotificationManager)
                _context.getSystemService(Context.NOTIFICATION_SERVICE);

        Notification notification = new Notification(R.drawable.menu_cartable,
                "you have a new message",
                System.currentTimeMillis());
        notification.flags = Notification.FLAG_AUTO_CANCEL;
        notification.sound = RingtoneManager
                .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);

        Intent notificationIntent = new Intent(_context, ActCartable.class);
        PendingIntent intent = PendingIntent.getActivity(_context, 0,
                    notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);

        notification.setLatestEventInfo(_context,
                "you have a new message",
                msg,
                intent);

        mNotificationManager.notify(NOTIFICATION_ID, notification);

    }

ここに画像の説明を入力 ここに画像の説明を入力

Android 4.2 では、初めてメッセージを受信すると (通知バーがクリアされます)、大きなアイコン(tickerText) が通知バーに表示され、数秒後に非表示になり、通知が通知バーに移動します。その通知を開かず (通知バーがクリアされていない)、2 番目のメッセージが受信された場合、大きなアイコンは再び表示されませんが、デバイスは正しく音を出し、新しいメッセージの内容は通知バーで正常に更新されます。通知バーを開きます。

Android 3.x では常に大きなアイコンが表示されることに注意してください。

新しいメッセージが受信され、通知バーがクリアされないたびに、Android 4.x でその大きなアイコンを表示するにはどうすればよいですか?

4

1 に答える 1