Using the native sms app to send an sms without launching itself

前端 未结 5 1162
忘掉有多难
忘掉有多难 2020-12-15 14:48

I want to send an SMS, but not using the SmsManager class. I want to do it with the native SMS app which is there on an Android phone.

And here is the twist : I do

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-15 15:38

    Ok, so you want to send a SMS, without using SmsManager and plus it should show up in your native SMS app list?

    Firstly, you cannot send SMS bypassing SmsManager. If you look at the source code of all native messaging app for Samsung Galaxy Nexus, it will invoke SmsManager on button click.

    so, the below piece of code as posted above is correct

    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, null, null);
    

    Secondly, after sending the message, native apps put it into into SMS ContentProvider

    follow this How to save SMS to inbox in android?

    Word of caution is that now adding to this is not supported. So you may have to resort to a hack to add it into the sent box.

提交回复
热议问题