Android: OneSignal comment changer de Notification projet de loi icône avec une icône personnalisée ou de l'icône de l'application?

Lors de la réception de la notification du projet de loi icône est affichée à la place de l'icône de l'application ou de l'icône personnalisée que je remplace pour l'afficher à partir du code. j'ai pu changer l'icône du tableau de bord, mais je veux à partir du code

Intilaization

    OneSignal.startInit(this)
            .inFocusDisplaying(OneSignal.OSInFocusDisplayOption.Notification)//to hide dialog
            .setNotificationOpenedHandler(new ExampleNotificationOpenedHandler())
            .init();

Classe de récepteur

  class ExampleNotificationOpenedHandler implements OneSignal.NotificationOpenedHandler
{
//This fires when a notification is opened by tapping on it.
@Override
public void notificationOpened(OSNotificationOpenResult result)
{
OSNotificationAction.ActionType actionType = result.action.type;
JSONObject data = result.notification.payload.additionalData;
String customKey;
Intent intent = new Intent(Roshetta.app, SplashActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK);
int requestCode = 0;
PendingIntent pendingIntent = PendingIntent.getActivity(Roshetta.app, requestCode, intent, PendingIntent.FLAG_ONE_SHOT);
Uri sound = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
android.support.v4.app.NotificationCompat.Builder noBuilder = new android.support.v4.app.NotificationCompat.Builder(Roshetta.app)
.setSmallIcon(R.mipmap.ic_launcher).setLargeIcon(largeIcon).setContentTitle(result.notification.payload.title)
.setContentText(result.notification.payload.body )
.setAutoCancel(true).setDefaults(android.app.Notification.DEFAULT_ALL)
.setContentIntent(pendingIntent).setSound(sound);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, noBuilder.build()); //0 = ID of notification
if (data != null)
{
customKey = data.optString("customkey", null);
if (customKey != null)
Log.i("OneSignalExample", "customkey set with value: " + customKey);
}
if (actionType == OSNotificationAction.ActionType.ActionTaken)
Log.i("OneSignalExample", "Button pressed with id: " + result.action.actionID);
Log.i("OneSignalExample", "ExampleNotificationOpenedHandler");

}

InformationsquelleAutor Mina Farid | 2016-11-17