有没有办法开辟消息活动在Android上一个特定的短信?
Answer 1:
threadId
应该是短信的ID / MMS线程要查看
Intent defineIntent = new Intent(Intent.ACTION_VIEW);
defineIntent.setData(Uri.parse("content://mms-sms/conversations/"+threadId));
myActivity.startActivity(defineIntent);
这是我发现的最简单方法
Answer 2:
试试这个
int req_thread_id;
Uri mSmsinboxQueryUri = Uri.parse("content://sms"));
Cursor cursor1 = getContentResolver().query(
mSmsinboxQueryUri,
new String[] { "_id", "thread_id", "address", "person", "date",
"body", "type" }, null, null, null);
startManagingCursor(cursor1);
if (cursor1.getCount() > 0)
{
while (cursor1.moveToNext())
{
int thread_id = cursor1.getInt(1);
String address; = cursor1.getString(cursor1
.getColumnIndex(columns[0]));
if("your desired no".equals(address)
req_thread_id = thread_id;
}
}
Intent defineIntent = new Intent(Intent.ACTION_VIEW);
defineIntent.setData(Uri.parse("content://mms-sms/conversations/"+req_thread_id));
myActivity.startActivity(defineIntent);
Answer 3:
我挖了这一点源的消息应用程序(的线311-315 ),所以我敢肯定它会工作,但我没有任何与它的经验。
// threadId should be the id of the sms/mms thread you want to view
long threadId = 0;
Intent i = new Intent("com.android.mms");
i.setData(
Uri.withAppendedPath(
i.getData(), Long.toString(threadId)
)
);
i.setAction(Intent.ACTION_VIEW);
Answer 4:
这片段是从接受的答案评论。 张贴在这里为后人的方法。
public static long findThreadIdFromAddress(Context context, String address) {
if (address == null)
return 0;
String THREAD_RECIPIENT_QUERY = "recipient";
Uri.Builder uriBuilder = THREAD_ID_CONTENT_URI.buildUpon();
uriBuilder.appendQueryParameter(THREAD_RECIPIENT_QUERY, address);
long threadId = 0;
Cursor cursor = null;
try {
cursor = context.getContentResolver().query(
uriBuilder.build(),
new String[] { Contacts._ID },
null, null, null);
if (cursor != null && cursor.moveToFirst()) {
threadId = cursor.getLong(0);
}
} finally {
if (cursor != null) {
cursor.close();
}
}
return threadId;
}
文章来源: How to open up a specific SMS in android