R
R
rsatarov2019-05-05 15:45:24
Java
rsatarov, 2019-05-05 15:45:24

How to fix the gray icon in the notification shade?

When creating a notification, the application icon in the status bar is displayed normally.

Screen 1
5cced9c5c0a09791502200.jpeg

But if you look in the curtain, then it turns gray.
Screen 2
5cced9d1960ec397359101.jpeg
The code that creates the notification.
private void createNoteNotification(int noteId) {
    AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
    Intent intent = new Intent(this, AlarmReceiver.class);
    intent.putExtra("id", noteId);
    intent.putExtra("dateTime", notificationDateTime);
    intent.putExtra("title", titleField.getText().toString());
    intent.putExtra("text", noteTextField.getText().toString());
    PendingIntent alarmIntent = PendingIntent.getBroadcast(this, noteId, intent, 0);
    alarmManager.setExact(AlarmManager.RTC, notificationDateTime, alarmIntent);
}

public static class AlarmReceiver extends BroadcastReceiver {
    public AlarmReceiver() {
    }
    @Override
    public void onReceive(Context context, Intent intent) {
        int id = intent.getIntExtra("id", 0);
        long dateTime = intent.getLongExtra("dateTime", 0);
        String title = intent.getStringExtra("title");
        String text = intent.getStringExtra("text");

        Intent deleteIntent = new Intent(context, DeleteNoteService.class);
        deleteIntent.putExtra("id", id);
        deleteIntent.setAction(DeleteNoteService.ACTION_DELETE_NOTE);
        PendingIntent deletePendingIntent = PendingIntent.getService(context, id, deleteIntent, 0);

        NotificationCompat.Builder builder = new NotificationCompat.Builder(context, context.getString(R.string.notification_channel_id))
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(title)
                .setContentText(text)
                .setStyle(new NotificationCompat.BigTextStyle().bigText(text))
                .setWhen(dateTime)
                .addAction(R.drawable.ic_delete_white_24dp, context.getString(R.string.delete), deletePendingIntent);

        ((NotificationManager) context.getSystemService(NOTIFICATION_SERVICE)).notify(id, builder.build());
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rsatarov, 2019-05-05
@rsatarov

The issue is resolved by creating another icon through the Asset Editor.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question