How to apply a big view style to a notification using Parse library

前端 未结 8 862
孤街浪徒
孤街浪徒 2021-02-04 06:03

This library works perfectly, but i have a doubt.

When I send a message to users with more than two lines, users can\'t see all message in notification area.

But

相关标签:
8条回答
  • 2021-02-04 06:52

    you can build notification with big Text Style try this code

     Intent intent = new Intent(this, MainActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
                PendingIntent.FLAG_ONE_SHOT);
    
        Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                .setSmallIcon(R.mipmap.ic_launcher)
                .setContentTitle(title)
                .setContentText(messageBody)
                .setAutoCancel(true)
                .setSound(defaultSoundUri)
                .setContentIntent(pendingIntent);
    
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    
        notificationManager.notify(id /* ID of notification */, notificationBuilder.build());
    
    0 讨论(0)
  • 2021-02-04 06:56

    This snippet shows how to construct the Builder object. It sets the style for the big view to be big text, and sets its content to be the reminder message.

    String msg="This is Big style notification builder.This is Big style notification  builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder.This is Big style notification builder."
    
    // Constructs the Builder object.
    NotificationCompat.Builder builder =
        new NotificationCompat.Builder(this)
        .setSmallIcon(R.drawable.ic_stat_notification)
        .setContentTitle(getString(R.string.notification))
        .setContentText(getString(R.string.ping))
        .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission
        .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
    
    final NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    nm.notify(0, builder.build());
    

    For more infomation go to:http://developer.android.com/training/notify-user/expanded.html

    0 讨论(0)
提交回复
热议问题