【发布时间】:2013-07-31 08:55:47
【问题描述】:
我正在尝试将数据从通知传递到活动:
btnShedule.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Intent notificationIntent = new Intent(Oconf.this, Oconf.class);
notificationIntent.putExtra("test", 122);
PendingIntent contentIntent = PendingIntent.getActivity(Oconf.this, 0, notificationIntent, 0);
Notification notification = new Notification(R.drawable.notify_deal, "text", System.currentTimeMillis());
notification.setLatestEventInfo(Oconf.this, getString(R.string.notify_events), "text", contentIntent);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(0, notification);
}
});
然后,onResume:
public void onResume() {
String q = getIntent().getStringExtra("test");
if (q == null) {
Log.e(TAG, "null!");
}
else {
Log.e(TAG, q);
}
super.onResume();
}
我得到“null!”。哪里出错了?
【问题讨论】:
标签: android notifications