I think what you are looking for is one of the new features introduced by Lollipop(API21) in the notification system.
Making use of the new property visibility, class Notification, it is possible to indicate to the system when and how it should reveal the presence and content of a notification.
There are 3 types of "visibility":
- Secretive (Notification.VISIBILITY_SECRET) - Notification is considered sensitive and is not shown in "lock screen". This is the default behavior(default).
- Privy (Notification.VISIBILITY_PRIVATE) - The notification is considered sensitive only with respect to the content. It is presented in "lock screen" but the content of the message is replaced by "Contents Hidden".
- Public (Notification.VISIBILITY_PUBLIC) - The notification is considered to be non-sensitive and the notification is fully shown on "lock screen"
The property can be "set" using the Notification.Builder.
Notification notification = new Notification.Builder(this)
.setCategory(Notification.CATEGORY_MESSAGE)
.setContentTitle(title)
.setContentText(text)
.setSmallIcon(icon)
.setAutoCancel(true)
.setVisibility(Notification.VISIBILITY_PUBLIC).build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(notification_id, notification );
Note: This property is only available from API21. A appcompat makes it accessible and can be used, but its effect is only felt on a device with Android 5 or more.
Good morning my dear! Do you know you will face many problems getting away from this? I advise you to take a look at Q-communicate, using the Quickblox. Download it and import a project and study it well. Surely you will learn a lot.
– viana
You want to open an Activity instead of appearing the notification?
– ramaral
@ramaral would be just that, I imagine that the image of Whatsapp, is an Activity and not a simple notification. Because there are many actions that can be taken from that screen and if you answer she has to give a Unlock on the device and open the app to make the call
– Erick Gallani
I’ve never used Whatsapp, does it appear without user intervention? Can you put the code your app uses for sharpening?
– ramaral
Basically what happens in the Whats app is as follows. If you make a call (call) to another user in the Whats app, this screen is displayed to answer the call (accepting or rejecting it). And this screen of the image I put up is presented exactly like this, even when the device is locked and at rest.
– Erick Gallani
Unfortunately I won’t be able to post the code now, I don’t have access to it right now.
– Erick Gallani