Notification中怎么传值给下一个Activity

Java code?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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);



#1 得分:40回复于: 2012-08-20 17:04:58

这样

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

如果您对CSDN论坛有意见和建议 请直接在本帖指教

对我有用[1] 丢个板砖[0] 引用 | 举报 | 管理


你可能感兴趣的:(Notification中怎么传值给下一个Activity)