user192629
user192629

Reputation: 303

Android: Adding a button on a status bar notification

I am trying to create a custom status bar notification in Android that has a button in addition to the text. The button can do a different thing than when you click the notification itself. Is this possible at all? I'd also be ok putting an image of a button there instead. I know how to put an image, but not sure how to handle OnClick for an image embedded in RemoteViews. Your help is sincerely appreciated.

Thanks a lot in advance.

Upvotes: 18

Views: 15006

Answers (3)

Falcon
Falcon

Reputation: 1367

I am working on this end as well. It is straightforward from HoneyComb onwards: look at the music app (it has a status bar control when playing). And you can implement yours with your_notification_remote_view_instance.setOnClickPendingIntent(R.id.a_button_in_notification, pending_intent_to_be_handled_by_a_service); while backing it with a service to handle the intent properly of course. While buttons can be embedded in earlier versions, they don't get focus or click when pressing.

Upvotes: 1

user998953
user998953

Reputation: 674

try use this way,the first is the view ID, the second is a Pending intent..

RemoteViews.setOnClickPendingIntent(R.id.push_notifi_content, Pdit);

I have try it,but seems it just support in android4.0

Upvotes: 1

FixerMark
FixerMark

Reputation: 749

I don't think you can get a button on the status bar itself but you can certainly do it using a Custom Expanded View (see http://developer.android.com/guide/topics/ui/notifiers/notifications.html)

Upvotes: 4

Related Questions