Je travaille dans une application Android Notifications. Je suis en mesure d'obtenir les notifications parfaitement, mais impossible d'afficher une image sur Notification. La notification était comme indiqué ci-dessous. Image vide s'affichait dans ma barre de notification
ceci est mon build.gradle Fichier
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
Je suivais le dessous Dimentions
24 × 24 (mdpi)
36 × 36 (hdpi)
48 × 48 (xhdpi)
7 2 × 72 (xxhdpi)
96 × 96 (xxxhdpi)
et mon code a été
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++;
}
Je trouve que nous devons utiliser l'image de notification transparente pour la notification . J'ai utilisé la transparence dans mon fond d'image mais encore une fois j'ai eu la même couleur blanche que le contour au lieu de l'Icon Outline de ma notification Originale qui est de couleur rouge – basha