我正在开发一个应用并使用推送通知。我的应用包含ID列表。点击特定ID,我可以看到与id相关的详细信息。
推送通知包含一个ID,所以我希望如果我点击推送通知,那么它将打开id的详细信息页面,以显示与通知中的id相关的详细信息。
例如 在我的应用程序中,我有多少ID(例如123,456,657 ...),如果我点击123,它将显示与id相关的详细信息,如姓名,电话号码,电子邮件等..我的推送通知包含123,我希望如果我点击推送通知,它将打开123 id的详细信息页面。
答案 0 :(得分:0)
使用PushNotification,您将在应用程序的本地数据库或WebService调用ID或其他任何内容中为您的项目传递一些ID。
为该DetailActivity创建一个挂起的意图,并在此包中为此传递此ID ..并在此处从bundle中编写getId代码,并基于从数据库或WebService获取数据。
如果有任何查询可以随意询问..
答案 1 :(得分:0)
您必须将id
作为与通知关联的意图的额外内容:
NotificationCompat.Builder builder = new NotificationCompat.Builder(this).setSmallIcon(R.drawable.ic_launcher)
.setAutoCancel(true);
// Create intent and set extra
Intent targetIntent = new Intent(this, <YourDetailsActivity>.class);
targetIntent.putExtra("id", id);
// Associate intent to notification
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, targetIntent, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIntent);
// Create notification...
Notification notification = builder.build();
// ...and show it
NotificationManager nManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nManager.notify(<YOUR_NOTIFICATION_ID>, notification);