Android notfication BigPictureStyle disappearing text

孤人 提交于 2019-12-02 20:38:10

Is there any setMessage() method I am forgetting to call?

Yep! NotificationCompat.BigPictureStyle setSummaryText

 mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
 mNotificationManager.notify(0, setBigPictureStyleNotification()); 

private Notification setBigPictureStyleNotification() {
    Bitmap remote_picture = null;

    // Create the style object with BigPictureStyle subclass.
    NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
    notiStyle.setBigContentTitle("Big Picture Expanded");
    notiStyle.setSummaryText("Nice big picture.");

    try {
        remote_picture = BitmapFactory.decodeStream((InputStream) new      URL(sample_url).getContent());
    } catch (IOException e) {
        e.printStackTrace();
    }

    // Add the big picture to the style.
    notiStyle.bigPicture(remote_picture);

    // Creates an explicit intent for an ResultActivity to receive.
    Intent resultIntent = new Intent(this, ResultActivity.class);

    // This ensures that the back button follows the recommended convention for the back key.
    TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

    // Adds the back stack for the Intent (but not the Intent itself).
    stackBuilder.addParentStack(ResultActivity.class);

    // Adds the Intent that starts the Activity to the top of the stack.
    stackBuilder.addNextIntent(resultIntent);
    PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

    return new NotificationCompat.Builder(this)
            .setSmallIcon(R.drawable.ic_launcher)
            .setAutoCancel(true)
            .setLargeIcon(remote_picture)
            .setContentIntent(resultPendingIntent)
            .addAction(R.drawable.ic_launcher, "One", resultPendingIntent)
            .addAction(R.drawable.ic_launcher, "Two", resultPendingIntent)
            .addAction(R.drawable.ic_launcher, "Three", resultPendingIntent)
            .setContentTitle("Big Picture Normal")
            .setContentText("This is an example of a Big Picture Style.")
            .setStyle(notiStyle).build();
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!