我是上学期学生的计算机科学专业的学生。 我有问题: 我将我的Android应用程序设置为从作业查找器Web应用程序的在线数据库接收通知。当新条目发生时,通知将在Android App上发布。 所以现在我想要,如果我点击该通知,那么将打开一个页面,其中将显示该作业的详细信息。
所以请告诉我,我只有几天时间来提交我的最后一年项目。 我将非常感谢。
答案 0 :(得分:0)
查看Android Developers Guide。他们在那里描述了设置PendingIntent
以响应通知点击。
PendingIntent resultPendingIntent;
...
mBuilder.setContentIntent(resultPendingIntent); // Code comes directly from this Developer Guide
答案 1 :(得分:0)
单击通知时,您必须使用Pending Intent打开页面。
// 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。
答案 2 :(得分:0)
创建通知:
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);
我希望它会有所帮助。