【发布时间】:2010-12-17 16:14:20
【问题描述】:
我正在使用广播监听器来收听传入的电话统计信息,然后推送这样的通知:
CharSequence contentTitle = "Contact: " + number;
CharSequence contentText = "Call From: " + number;
Intent notificationIntent = new Intent(context, CallHandler.class);
notificationIntent.putExtra(KEYS.NUMBER, number);
notificationIntent.putExtra(KEYS.STATE, stat);
notificationIntent.putExtra(KEYS.NAME, name);
notificationIntent.putExtra(KEYS.DURATION, duration);
notificationIntent.putExtra(KEYS.START_TIME, startTime);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notif.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notif.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify((int) System.currentTimeMillis(), notif);
因此,当有多个呼叫时,我希望有多个呼叫通知,当我单击每个通知时,我希望使用附加参数启动一个活动。但是,我可以看到稍后开始的活动获得了上一个调用的 Intent。
这是我从 Activity 中查看意图的方式
Bundle extras = getIntent().getExtras();
String number = extras.getString(KEYS.NUMBER);
// String state = extras.getString(KEYS.STATE);
long duration = extras.getLong(KEYS.DURATION);
Date start = getStartDate();
((TextView) findViewById(R.id.subject)).setText("");
((TextView) findViewById(R.id.start_time)).setText(tf.format(start));
((TextView) findViewById(R.id.end_time)).setText(tf
.format(getEndDate()));
((TextView) findViewById(R.id.caller_number)).setText(number);
((TextView) findViewById(R.id.notes)).setText(getNotesDefaultContent(
number, duration, start));
如何保持 Intent 分别调用独立的活动?
【问题讨论】:
-
我在这里遇到了同样的问题:stackoverflow.com/questions/4340431/… 仍然无法弄清楚
标签: android