首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Notification中如何传值给上一个Activity

2012-08-31 
Notification中怎么传值给下一个ActivityJava codenotificationManager (NotificationManager) getSyste

Notification中怎么传值给下一个Activity

Java code
notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);                    Notification notification = new Notification(                            android.R.drawable.stat_notify_chat, "Hello",                            System.currentTimeMillis());                    Intent notificationIntent = new Intent(MyNotification.this,                            SendActivity.class);                    System.out.println("xy="+xy);                                            notificationIntent.putExtra("xy", xy);                                        PendingIntent pIntent = PendingIntent.getActivity(                            MyNotification.this, 0, notificationIntent, 0);                    notification.setLatestEventInfo(MyNotification.this,                            contentTitle, contentText + "**" + str, pIntent);                    System.out.println("Handler  id=" + MyNotification.ID);                    notificationManager.notify(MyNotification.ID, notification);


Activity中的代码

Intent intent=getIntent();

int kk=intent.getIntExtra("xy", 0);

[解决办法]
这样

PendingIntent pendingIntent = PendingIntent.getActivity(this, id, intent, PendingIntent.FLAG_UPDATE_CURRENT);

热点排行