开发者

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

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/conversations/"+threadId

Currently I'm using SMSManager:

SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phone, null, message, null, null);  
开发者_StackOverflow中文版

Is there any ways to do this across all the devices considering each of them has a different SMS app. Thanks in advance.


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);


You need to use the following value:

values.put("thread_id", threadId);

And it will be associated with the thread.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜