0

我在将数据放入意图和读取数据之间存在数据不匹配的问题。在我的服务中,我正在创建通知并向意图添加参数。当我看到通知时,参数没问题。但是当我打开通知时,参数行为是有线的。我在我的系统中获得了真实的参数,但一旦我发送就没有。这个问题是因为我在我的服务中创建通知吗?

public void createNotification(ChatMessage message) 
{

    Notification notification = new Notification(R.drawable.ic_action_sm, 
                                                 "Message From" +
                                                 " " + message.getSenderName(),
                                                 System.currentTimeMillis());

    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    Intent intent = new Intent(this, ChatActivity.class);
    intent.putExtra("userProfile", message.getReciverChatProfile());        
    intent.putExtra("friendProfile", message.getSenderChatProfile());

    PendingIntent activity = PendingIntent.getActivity(this, 0, intent, 0);

    notification.setLatestEventInfo(this,
                                    message.getSenderName(),
                                    message.getMessage(),
                                    activity);
    notification.number += 1;
    notification.iconLevel = 3;
    notificationManager.notify(0, notification);
} 
4

1 回答 1

0

添加 FLAG_UPDATE_CURRENT 解决了这个问题。

PendingIntent activity = PendingIntent.getActivity(this, 0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
于 2012-09-12T10:05:23.970 回答