【问题标题】:android: getting same value from Intent extrasandroid:从 Intent extras 中获得相同的价值
【发布时间】:2011-06-17 10:37:14
【问题描述】:

我这样做是为了创建一个 Intent。

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() 中取回了相同的值。

我做错了什么?

【问题讨论】:

  • 这些都是不同的活动吗..
  • 对不起,我不理解不同的活动..

标签: android android-intent bundle extras


【解决方案1】:

【讨论】:

  • 这行得通! notificationIntent.setAction("actionstring" + System.currentTimeMillis()); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
【解决方案2】:

使用这个

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);

检查结果

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-05
    • 2019-12-12
    • 2020-01-12
    相关资源
    最近更新 更多