Android 通过登录在通知clcik上发送额外信息
我有通知,点击后,我需要进入MainActivity页面输入密码和登录名,然后进入ItemDetail活动页面。但在发送通知时,我有一些额外的内容需要传递到ItemDetail活动页面,因为我有MainActivity,我将如何从点击发送到ItemActivityAndroid 通过登录在通知clcik上发送额外信息,android,Android,我有通知,点击后,我需要进入MainActivity页面输入密码和登录名,然后进入ItemDetail活动页面。但在发送通知时,我有一些额外的内容需要传递到ItemDetail活动页面,因为我有MainActivity,我将如何从点击发送到ItemActivity private void sendNotification(String msg, int invM_id, int prmR_id) { try { Intent notificationInten
private void sendNotification(String msg, int invM_id, int prmR_id) {
try {
Intent notificationIntent = new Intent(this, ItemActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);
data1=WebService.InvoiceDetailForExeedDiscount1(invM_id);
***//I need these data in ItemActvity,i can read this before introducing MainActivity in between***
notificationIntent.putExtra("invoiceList", data1);
notificationIntent.putExtra("notified","yes");
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
mNotificationManager = (NotificationManager)
this.getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle(getString(R.string.invoice_alert))
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(msg))
.setContentText(msg);
reminderStrings.append(prmR_id);
reminderStrings.append(",");
mBuilder.setContentIntent(contentIntent);
mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
NOTIFICATION_ID++;
}
你不能做双传球。您必须分两步完成,例如,将所有信息传递给MainActivity,然后可能在MainActivity内部,完成该表单后检查是否有该信息,如果有,将其传递给ItemActivity您不能重复传递。您必须分两步完成,例如将所有信息传递给MainActivity,然后可能在MainActivity内部,在完成该表单后检查是否有该信息,如果有,将其传递给ItemActivity如果您需要iti提供的信息,恐怕您必须启动其他活动如果您需要iti提供的信息,恐怕您必须启动其他活动