如何通过待处理的意图传递线程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());
答案 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());