如何监听Android上notififation酒吧onClick事件? [英] How to listen onClick event for notififation bar on Android?
本文介绍了如何监听Android上notififation酒吧onClick事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好吧,我有一个简单的通知。但是,当我在通知栏点击它,我只是得到我开的应用程序。所以,我怎么能知道我的应用程序被通知水龙头打开或我怎么能攻后打开特定的活动?
Well, I have a simple notification. But when I tap it in Notification bar, I just get opened my app. So how can I know that my app was opened by notification tap or how can I open a specific Activity after tapping?
推荐答案
我觉得你有状态栏通知
这code。当您单击通知项,以下意图
被调用。
I think you have this code in Statusbar Notification
. When you click the Notification Item, the following Intent
is called.
Context context = ctx.getApplicationContext();
Intent notificationIntent = new Intent(ctx, ctx.getClass());
PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
如果您想具体活动
要打开,请致电特定类以上意图
If you want specific Activity
to be opened, call the particular Class in the above Intent
这篇关于如何监听Android上notififation酒吧onClick事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文