2016-01-26 51 views
0

我被困在通知中。 当我运行下面的代码下棒棒糖和棒棒糖,它工作正常。通知setStyle不在棒棒糖中工作

但是,如果我在棒棒糖中运行代码,setstyle()方法不起作用。 我也尝试过使用remoteviews,但它也不起作用。

我试过BigPicture,但它也不起作用。 我错过了什么? 请帮忙。

Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); 
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.ic_launcher) 
      .setLargeIcon(largeIcon) 
      .setContentTitle(title) 
      .setContentText(content) 
      .setVisibility(Notification.VISIBILITY_PUBLIC) 
      .setAutoCancel(true) 
      .setVibrate(new long[]{1000, 1000, 1000}) 
      .setSound(defaultSoundUri) 
      .setStyle(new NotificationCompat.BigTextStyle().bigText(content)) 
      .setContentIntent(pendingIntent); 

    NotificationManager notificationManager = 
      (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); 

我试过很多设备,发现它发生在android 5.0.2版本中。

回答

0

我不觉得除了setContentText任何问题()删除它,并给一个尝试以下操作:

Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); 
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.ic_launcher) 
      .setLargeIcon(largeIcon) 
      .setContentTitle(title) 
      .setVisibility(Notification.VISIBILITY_PUBLIC) 
      .setAutoCancel(true) 
      .setVibrate(new long[]{1000, 1000, 1000}) 
      .setSound(defaultSoundUri) 
      .setStyle(new NotificationCompat.BigTextStyle().bigText(content)) 
      .setContentIntent(pendingIntent); 

    NotificationManager notificationManager = 
      (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());