有沒有辦法在android上用特定的短信打開短信活動?如何在android中打開特定的短信
12
A
回答
9
threadId
應該是短信的ID/MMS線程要查看
Intent defineIntent = new Intent(Intent.ACTION_VIEW);
defineIntent.setData(Uri.parse("content://mms-sms/conversations/"+threadId));
myActivity.startActivity(defineIntent);
這是我發現
2
我從Messaging應用程序(lines 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);
+0
我覺得'線索ID'是不同於'短信ID'? 來自同一個人的不同短信(每個都有自己的ID)可以具有相同的線索ID。 – n179911 2009-09-14 17:48:02
4
試試這個
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);
0
這最簡單的方法摘錄來自接受答案中的評論。在這裏爲後人發佈方法。
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;
}
相關問題
- 1. 在Android中打開spefic短信線程
- 2. Android:如何從收件箱中獲取短信並刪除特定的短信
- 3. 如何在特定的速度(acclerometer)禁用短信在android
- 4. 如何讀取特定的手機號碼,短信中的Android
- 5. 在android中發送獨特的短信和接收looong短信
- 6. 如何發送短信從特定的SIM在Android
- 7. 如何攔截打開短信郵箱?
- 8. 如何在任何一個特定端口的短信接收時自動打開Android應用程序?
- 9. 如何在不打開短信應用程序的情況下發送短信
- 10. 如何開發Android短信視圖?
- 11. Android:從特定號碼接收短信?
- 12. 在Android中打開短信會話列表
- 13. 的Android應用程序,打開收件箱中的短信
- 14. Android短信中的特殊字符
- 15. 打破新行短信Android
- 16. Android預定短信
- 17. 如何在雙手機中發送特定SIM卡的短信
- 18. 在android上打開主要的短信會話意圖
- 19. Android:如何在雙卡手機中發送特定SIM卡的短信?
- 20. 如何在Android中發送長短信?
- 21. 如何在android中安排短信?
- 22. 如何在Android中收聽新短信
- 23. 如何在android中接收短信?
- 24. 如何在android中發送短信
- 25. 如何在android中接收短信?
- 26. 如何在android中刪除短信?
- 27. 如何在android照片庫中打開特定圖像?
- 28. Android如何在Gallery中打開特定導演
- 29. 如何中止短信的短信
- 30. 短信調度程序在特定時間用於短信
如何獲取短信的線索ID? – Janusz 2010-12-29 19:02:08
嘗試查看下面的findThreadIdFromAddress()方法:http://code.google.com/p/android-smspopup/source/browse/trunk/SMSPopup/src/net/everythingandroid/smspopup/SmsPopupUtils.java – 2011-09-17 12:38:41
@paul_sns Dead鏈接。 – VickyS 2014-03-01 12:19:57