Android 捕获通知事件(长按)
对通知的标准短按会触发其中保存的 PendingIntent。
是否可以捕获其他事件?
要求是捕获长按。
The standard short click on a Notification fires the PendingIntent held in it.
Is it possible to catch other events?
The requirement is to catch a Long Press.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尽管您可以使用 NotificationCompat 和 RemoteViews 您无法操纵底层点击行为。您唯一的选择就是更改少数 ViewType 的一些参数:
因此回答您的问题:不,使用最新的 Google API (api lvl 17 - 14.01.2013) 您无法插入onLongClickListener 到通知中的任何视图元素中。
为什么会这样?
RemoteView 只是视图的简化、更简单的派生。它甚至与视图(RemoteView 扩展对象)无关,因此不提供真实视图中的所有选项(View.setOnLongClickListener()) 。
什么是 RemoteView?:
如果您想获得更多见解,我推荐这些文章:
Although you can create custom Notification-Views with NotificationCompat and RemoteViews you have no means to manipulate underlying click-behavior. The only options you have got is to change some parameters for a handfull of ViewTypes:
So to answer your Question: No, with the most current Google API (api lvl 17 - 14.01.2013) you can not insert a onLongClickListener into any of the view-elements within a notification.
Why is this so?
RemoteView is only a boiled down, simpler derivate of a View. It is not even related to View (RemoteView extends Object) therefore does not provide all the options you would have in a real View (View.setOnLongClickListener()) .
What are RemoteViews?:
If you want more insight I recommend these articles:
就像应用程序小部件一样,它是远程视图,仅支持点击和垂直拖动手势
Just like an app-widget, it's a remote view, it only supports tap and vertical drag gesture