Vivart
Vivart

Reputation: 15313

How to make notification like phone app

In samsung galaxy tab 2 when phone app goes to background, we can interact with phone app from notification. it has all the buttons and information that we need. enter image description here

How can i implement notification like this?

Upvotes: 2

Views: 231

Answers (1)

Ovidiu Latcu
Ovidiu Latcu

Reputation: 72311

First of all you can add functional buttons to your Notification just on devices running Honeycomb or later. Yes, some pre Honeycomb devices have those kind of Notifications, but only the device manufacturers were able to build such Notifications (examples for Dialer or Music Player).

To use such a notification you could use a customView for your Notification (have a look at RemoteViews).

An easier way,(and the recommended way) would be to use NotificationCompat.Builder and use the addAction method, wich will add a button to your Notification and execute the PendingIntent that you specify, when that button is clicked. This will also work on pre Honeycomb devices, meaning that on older devices will not show the button.

EDIT: you can refer to this great tutorial from Vogella : Android Notifications.

Upvotes: 3

Related Questions