我通过通知的意图发送一些数据(字符串)。但是,当我尝试通过通知发起的活动接收它时,我什么也收不到。这是我的代码。请帮忙。如何检索通过意图传递的数据?
这是通知代码:
int icon=R.drawable.ic_launcher;
String ticket="Encrypted message";
long when=System.currentTimeMillis();
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Context context1 =getApplicationContext();
String expandedText="You've received an encrypted message, click to view";
String expandedTitle="Encrypted Message";
Notification notification = new Notification(icon, ticket, when);
Intent intent1=new Intent(context,Try.class);
intent1.putExtra("MSG","Jumbo");
PendingIntent launchIntent=PendingIntent.getActivity(context,0, intent1,0);
notification.setLatestEventInfo(context,expandedTitle,expandedText,launchIntent);
mNotificationManager.notify(1,notification);
这里是我如何接受它在Try.class:
t = (TextView)findViewById(R.id.dec);
String d = "";
Intent I = getIntent();
d = I.getStringExtra("MSG");
String text = "This is an example";
t.setText(d);
没有错误 - TextView的设置为什么都没有,当我运行它
它在'onCreate()'方法 – Saturnian