1

I am working in an android app Notifications . I am able to get the Notifications perfectly but Unable to display an image on Notification. The Notification was as shown in the below . enter image description here

this is my Build.gradle File

 compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.ex.myfile"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "2.5"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true

I followed the below Dimentions

24 × 24 (mdpi)

36 × 36 (hdpi)

48 × 48 (xhdpi)

72 × 72 (xxhdpi)

96 × 96 (xxxhdpi)

and My Code was

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder;
        notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.notification_icon)
                .setContentTitle(getString(R.string.app_name))
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);

        if (jsonobj.has("streamURL")) {
            notificationBuilder.setContentText(jsonobj.getString("userName") + " is LiveNow");
        } else if ((jsonobj.has("title") && (jsonobj.has("message")))) {
            notificationBuilder.setContentText(allFilesDataModel.getFileTitle() + " " + allFilesDataModel.getMessage());
        } else {
            notificationBuilder.setContentText("new Video was Uploaded To YouTube");
        }

        // notificationBuilder.setContentText("" + allFilesDataModel.getFileApprovedOrDenied());
        NotificationManager notificationManager = (NotificationManager)
                getSystemService(Context.NOTIFICATION_SERVICE);

        notificationManager.notify(NOTIFICATION_ID, notificationBuilder.build());
        NOTIFICATION_ID++;
    }
basha
  • 587
  • 2
  • 6
  • 25

1 Answers1

0

Please check this. You'll need to use two different icons for API >= 21.

in setSmallIcon() you'll need to pass proper icon for API >= 21

Sandip Fichadiya
  • 3,430
  • 2
  • 21
  • 47
  • I found that we have to use transparent Notification Image for the notification. I used transparency in my image background but again I got the same white color as outline instead of my Original notification's Icon Outline which is red color – basha Sep 09 '17 at 04:19