Android send SMS which is visible in SMS thread (no GUI)

前端 未结 2 1134
醉梦人生
醉梦人生 2020-12-13 22:31

What I need:
- Send SMS with no GUI interaction (choosing a client to send SMS is out)
- SMS has to be visible in a thread queried from \"content://mms-sms/conversat

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-13 22:52

    Just figured it out, you can use ContentResolver to insert the SMS and remember to add permissions: "uses-permission android:name="android.permission.WRITE_SMS"

       ContentValues values = new ContentValues();
       values.put("address", phone);
       values.put("body", message);
       getContentResolver().insert(Uri.parse("content://sms/sent"), values);
    

提交回复
热议问题