我是上学期计算机科学专业的学生。我有问题:我设置我的安卓应用程序接收通知,从在线数据库的求职网络application.When发生新的条目,然后通知来这里的安卓应用程序。因此,现在我希望,如果我单击该通知,将打开一个页面,其中将显示该作业的详细信息。
所以请告诉我,我只有几天的时间来提交我的最后一年的项目。我会非常感谢的。
发布于 2015-05-06 14:58:15
看一看Android Developers Guide。在那里,他们描述了如何设置一个PendingIntent来对点击通知做出反应。
PendingIntent resultPendingIntent;
...
mBuilder.setContentIntent(resultPendingIntent); // Code comes directly from this Developer Guide发布于 2015-05-06 15:00:09
单击通知时,您必须使用待定意图才能打开页面。
// prepare intent which is triggered if the
// notification is selected
Intent intent = new Intent(this, YourActivityToBeOpen.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);您可以在here上找到更多详细信息。
发布于 2015-05-06 15:03:45
要创建通知:
NotificationManager mgr = (NotificationManager)this.getSystemService(Context.NOTIFICATION_SERVICE);
Notification note = new Notification(R.drawable.stat_notify_chat,
"Android Example Status message!",
System.currentTimeMillis());
// This pending intent will open after notification click
Intent i = new Intent(this, NotifyMessage.class);
PendingIntent i = PendingIntent.getActivity(this, 0, i, 0);
note.setLatestEventInfo(this, "Android Example Notification Title",
"This is the android example notification message", i);
// After uncomment this line you will see number of notification arrived
// note.number=2;
mgr.notify(NOTIFY_ME_ID, note);Intent i = new Intent(this, NotifyMessage.class);
PendingIntent i = PendingIntent.getActivity(this, 0, i, 0);它会在点击通知后管理您的导航。如果您不想要导航,则使用:
Intent i = new Intent();
PendingIntent i = PendingIntent.getActivity(this, 0, i, 0);我希望它能有所帮助。
https://stackoverflow.com/questions/30069468
复制相似问题