如何在後臺運行Android應用程序來計算髮送的SMS消息的數量,並且另外確定每個消息的詳細信息?如何在Android應用程序的背景中檢測傳出的SMS消息?
4
A
回答
2
您可以獲取發送消息:
Uri mSmsinboxQueryUri = Uri.parse("content://sms/sent");
Cursor cursor1 = getContentResolver().query(mSmsinboxQueryUri,
new String[] { "_id", "thread_id", "address", "person", "date",
"body", "type" }, null, null, null);
startManagingCursor(cursor1);
String[] columns = new String[] { "address", "person", "date", "body","type" };
if (cursor1.getCount() > 0) {
String count = Integer.toString(cursor1.getCount());
Log.e("Count",count);
while (cursor1.moveToNext()){
String address = cursor1.getString(cursor1.getColumnIndex(columns[0]));
String name = cursor1.getString(cursor1.getColumnIndex(columns[1]));
String date = cursor1.getString(cursor1.getColumnIndex(columns[2]));
String msg = cursor1.getString(cursor1.getColumnIndex(columns[3]));
String type = cursor1.getString(cursor1.getColumnIndex(columns[4]));
}
}
可以使用計數器以檢索最近發來的短信。
請參閱其他有用的鏈接:
Android: Is there any way to listen outgoing sms?
-2
使用的服務。向通過braodcastreceiver發送短信時接收消息的服務註冊一個監聽器。
使用該清單中
<receiver android:name="SmsReceiver">
<intent-filter>
<action android:name=
"android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
代碼smsreceiver
public class SmsReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context context, Intent intent)
{
//here your code
}
}
+1
這適用於*傳入*文本消息,但OP正在詢問*傳出*文本。目前,沒有廣播接收傳出文本。 – Jag
相關問題
- 1. 檢測新的SMS/MMS消息Android應用程序
- 2. Android:檢測應用程序背景
- 3. 檢測Android應用程序去背景
- 4. 如何在應用程序中獲取MMS/SMS消息信息?
- 5. 在Windows Mobile應用程序中檢測傳入的短消息
- 6. 的Android - 檢測應用程序移動到背景和前景
- 7. 如何在前景中檢測到我的Android應用程序?
- 8. 檢測bb10應用程序去背景
- 9. 如何在我的Rails應用程序的背景中偵聽AWS SQS消息?
- 10. 如何將Android應用程序從前景傳遞到背景
- 11. 在我的應用程序中接收SMS消息
- 12. 如何在Android中運行iOS中的應用程序背景?
- 13. Android應用程序背景
- 14. Android背景應用程序
- 15. 如何在android應用程序的背景中撥打電話
- 16. 檢測應用程序背景中的搖動事件iOS7
- 17. 如何檢測推送通知,如果應用程序在iOS應用程序中的背景?
- 18. 如何以編程方式檢查Android上SMS消息大小
- 19. 如何在Android SMS應用程序中收到消息時自動顯示消息?
- 20. 如何從Java Web應用程序發送SMS消息
- 21. 背景上的時鐘應用程序「無警報」消息
- 22. 如何訪問時,我的應用程序在背景的Android
- 23. 如何在我的C#應用程序中獲取SMS傳遞?
- 24. 趕上Android應用程序的背景
- 25. Android應用程序的視頻背景
- 26. Android應用程序的背景圖像
- 27. Android中沒有背景應用程序
- 28. 如何以編程方式在Android中讀取SMS消息
- 29. 在Android中創建SMS應用程序?
- 30. 如何更改Android應用程序中的背景圖像?
出於某種原因內容://短信/ SENT不適合我,但工作內容://短信/做。你爲什麼認爲這是事實? – gonzobrains