Notification with setFullScreenIntent () for BigTextStyle open function automatically

I have a very strange problem, I am working on Push Notification and it was implemented successfully, but when I used BigTextStyle in Notification to show a long message in the notification area using the setFullScreenIntent () method, then the problem occurs when the notification is opened automatically, that set in PendingIntent.

If I do not use setFullScreenIntent (), the notification will not open the Activity automatically, the user needs to click or tap the Notification to open the Activity in the PendingIntent.

So there are two codes

  • Without setFullScreenIntent () works fine and doesn't open automatically:

    notification = new NotificationCompat.Builder(context)
                            .setContentTitle("Title")
                            .setContentIntent(resultPendingIntent)
                            .setContentText(message)
                            .setStyle(
                                    new NotificationCompat.BigTextStyle()
                                            .bigText(message))
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setAutoCancel(true);
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                manager.notify(1, notification.build());
    
          

  • With setFullScreenIntent () also works fine, but the Activity opens automatically: -

    notification = new NotificationCompat.Builder(context)
                            .setContentTitle("Title")
                            .setContentIntent(resultPendingIntent)
                            .setContentText(message)
                            .setStyle(
                                    new NotificationCompat.BigTextStyle()
                                            .bigText(message))
                            .setSmallIcon(R.drawable.ic_launcher)
                            .setFullScreenIntent(resultPendingIntent, true) //Whether true or false same result
                            .setAutoCancel(true);
    NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                manager.notify(1, notification.build());
    
          

-1


source to share


2 answers


public NotificationCompat.Builder setFullScreenIntent (PendingIntent intent, boolean highPriority)

The purpose of the launch is instead of posting a status bar notification. For use only with extremely high priority notifications that require the immediate attention of the user, such as an incoming phone call or an alarm that the user has explicitly set at a specific time. If this object is being used for anything else, please give the user the option to disable it and use normal notification as this can be extremely destructive.

On some platforms, the system's user interface may display a heads-up notification instead of triggering this intent while the user is using the device.

Parameters

Target: Pending launch intent.

highPriority: Passing true will send this notification even if other notifications are suppressed.

Found here . As you can see, this triggers the intent immediately. I really don't know in which case you wanted to use setFullScreenIntent()

?



Notification will not automatically expand when static notification is displayed on top (there may be a custom panel with Wi-Fi, Bluetooth and sound support)

+3


source


pass setFullScreenIntent and setContentIntent with different pending intents.



Worked for me. click "Notif" and autoplay will stop

0


source







All Articles