Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 意图中的数据不匹配_Java_Android - Fatal编程技术网

Java 意图中的数据不匹配

Java 意图中的数据不匹配,java,android,Java,Android,我有一个问题,就是将数据放在意图和读取数据之间的数据不匹配。 在我的服务中,我创建通知并向意图添加参数。 当我看到通知时,参数正常。但是,当我打开通知时,参数会以有线方式运行。我在我的系统中得到了真实的参数,但在发送后没有。 这个问题是因为我正在我的服务中创建通知吗 public void createNotification(ChatMessage message) { Notification notification = new Notification(R.drawable.

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

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

添加标志\u UPDATE\u CURRENT解决了问题

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