Android Notification without click event?

青春壹個敷衍的年華 提交于 2019-12-24 21:04:18

问题


I would like to try and make a Notification that does not respond to a click. Is this possible? i.e. when it is visible in the Notification area, and the user touches it, I want "nothing" to happen.

This is different to a normal Notification - when it is visible, and the user touches it, the Notification Area hides, and the Intent is launched. I do not want the Notification Area to hide when it is touched.


I can make one that doesn't launch an activity:

  • Possible to make an Android Notification that does not call an Intent?
  • Android - notification manager, having a notification without an intent

But it still responds to a click, by hiding the notification bar again (i.e. standard expected behaviour).


This question is a duplicate of How to disable a click event of notification in android development but that question does not have an answer. (if there is a better way to ~bump~ that question up again, I will do that & delete this question)


Note: I know this is not "the Android way", but it is still something I would like to try.


回答1:


I do not want the Notification Area to hide when it is touched.

That would require firmware modifications. You are not in control over the notification area; the OS is.




回答2:


Use Intent intent = new Intent() and insert this into the PendingIntent.



来源:https://stackoverflow.com/questions/8008500/android-notification-without-click-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!