开发者

Android - Buttons supported in notification expanded view?

开发者 https://www.devze.com 2023-01-28 20:09 出处:网络
I am trying to get buttons to work in notification expanded view.The goal is to use the buttons to launch activities from the notification view.Is this even supported?Here is a very simple outline wit

I am trying to get buttons to work in notification expanded view. The goal is to use the buttons to launch activities from the notification view. Is this even supported? Here is a very simple outline with irrelevant details omitted:

  1. Create a RemoteView object using a layout with some ImageButtons.
  2. Create pending intent for each button and set them using RemoteView.setOnClickPendingIntent(...)
  3. Create a Notification object and set it's contentView as the RemoteView created in step 1.
  4. Set Notification object's contentIntent.
  5. Send the Notifi开发者_StackOverflowcation.

This works beautifully on my Droid X. I can click on each button and launch it's associated activity successfully.

This works on my pal's Evo 4G as well, except that it launches the button's intent plus the notification's content intent. So two intents launched. But I can deal with that.

This also works on HTC Incredible.

Unfortunately, it doesn't work on most other phones: Vibrant, Hero, Vision, WildFire, MIleStone, Droid 1. These are the ones I know so far based on user feedback. On these phones, only the notification contentIntent is being launched. It appears the button's click events aren't being captured/detected.

I am at my wit's end trying to work around this. I am beginning to think it's impossible, but it works on some phones! Any suggestion/help is appreciated.

Thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消