我这样做是为了创建一个意图。
Intent notificationIntent = new Intent(this, Startup.class);
notificationIntent.putExtra("url", contentUrl);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
Notification notification = new Notification(icon, tickerText, when);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
获得额外的,
CharSequence url = this.getIntent().getCharSequenceExtra("url");
有许多Intent及其各自的url值。但是我也在Startup类的onCreate()中获得相同的值。
我做错了什么?
答案 0 :(得分:4)
这应该回答你的问题肯定...欢呼:) Android keeps caching my intents Extras, how to declare a pending intent that keeps fresh extras?
答案 1 :(得分:0)
使用此
PendingIntent contentIntent = PendingIntent.getActivity(this,0, notifyIntent,android.content.Intent.FLAG_ACTIVITY_NEW_TASK);
而不是
PendingIntent contentIntent = PendingIntent.getActivity(context,0,notificationIntent,PendingIntent.FLAG_UPDATE_CURRENT);
并检查结果