通知の意図を介していくつかのデータ (文字列) を送信しています。ただし、通知によって起動されたアクティビティで受信しようとすると、何も受信しません。これが私のコードです。助けてください。
これは、通知のコードです。
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は何も設定されません