Good all the time of day!

I ran into a problem that I need to display a notification on the lock screen. Starting with Android 5.0, everything works fine thanks to .setVisibility() , but I want to support the display of notifications on the lock screen and earlier versions (SDK <21), as well as to be able to respond to a button click on the notification.

My notification starts from the Service.

    2 answers 2

    To display an alert on the lock screen, you must set the priority higher than the standard one or 2. For example,

    The priority acts as a hint to the user interface of the device on how to display the notification. To set the notification priority, call the NotificationCompat.Builder.setPriority() method and pass it one of the NotificationCompat priority constants. There are five priority levels, ranging from PRIORITY_MIN (-2) to PRIORITY_MAX (2). If no priority is given, then by default it will be PRIORITY_DEFAULT (0).

    Also, to work with buttons in the notification, you must use an advanced layout. Read more here https://developer.android.com/guide/topics/ui/notifiers/notifications.html

    • It does not depend on the priority, if protection is set (graphic key, code ...), the notification will be shown, but its contents will be hidden. - Dzukaev

    Here is the solution to the problem - RemoteControlClient .

    • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (as well as comments) do not add knowledge to the Runet. - Nicolas Chabanovsky ♦