如何通过挂起的意图传递线程ID

时间:2016-05-16 09:21:22

标签: android

如何通过待处理的意图传递线程ID以打开确切的消息对话,例如当我们收到带有点击通知的消息并看到对话时

PendingIntent nPendingInten = PendingIntent.getActivity(context, 0, nIntent,
                            PendingIntent.FLAG_UPDATE_CURRENT);
    Intent intent = new Intent(context, ConvActivity.class);
                    intent.putExtra(ConvActivity.THREAD_ID_EXTRA, threadId);
                    intent.putExtra(ConvActivity.THREAD_NAME_EXTRA,listItem.getContactName());
                    intent.putExtra(ConvActivity.THREAD_IMAGE_EXTRA, uri);
                    intent.putExtra(ConvActivity.THREAD_NUM_EXTRA,listItem.getAddress());

2 个答案:

答案 0 :(得分:0)

您正在将另一个意图传递给您的未决意图 - 请注意。

 Intent intent = new Intent(context, ConvActivity.class);
                    intent.putExtra(ConvActivity.THREAD_ID_EXTRA, threadId);
                    intent.putExtra(ConvActivity.THREAD_NAME_EXTRA,listItem.getContactName());
                    intent.putExtra(ConvActivity.THREAD_IMAGE_EXTRA, uri);
                    intent.putExtra(ConvActivity.THREAD_NUM_EXTRA,listItem.getAddress());
    PendingIntent nPendingInten = PendingIntent.getActivity(context, 0, intent,
                                PendingIntent.FLAG_UPDATE_CURRENT);

答案 1 :(得分:0)

试试这段代码

PendingIntent nPendingInten = PendingIntent.getActivity(context, 0, nIntent,
                        PendingIntent.FLAG_UPDATE_CURRENT);
Intent intent = new Intent(context, ConvActivity.class);
                intent.putExtra(ConvActivity.THREAD_ID_EXTRA,    

threadId.longvalue);// change here
                intent.putExtra(ConvActivity.THREAD_NAME_EXTRA,listItem.getContactName());
                intent.putExtra(ConvActivity.THREAD_IMAGE_EXTRA, uri);
                intent.putExtra(ConvActivity.THREAD_NUM_EXTRA,listItem.getAddress());