Android: send an SMS message and run it in the "SMS" folder?

Finally I got my application for sending text messages (SMS), but now the problem is that I need messages to be displayed in the Inbox folder if the user opens the sms application.

Is there a way to add text messages to my inbox?

I am currently using the following code, can I change it in any way so that it appears in the inbox?

private void sendSMS(String phoneNumber, String message)
{
    PendingIntent pi = PendingIntent.getActivity(ccc, 0, new Intent(), 0);
    SmsManager sms = SmsManager.getDefault();
    sms.sendTextMessage(phoneNumber, null, message, pi, null);
} 
+5
source share
2 answers

This link contains an example of how to do this.

This function in the code does this; a complete example uses the service to complete the task:

private void addMessageToSent(String telNumber, String messageBody) {
    ContentValues sentSms = new ContentValues();
    sentSms.put(TELEPHON_NUMBER_FIELD_NAME, telNumber);
    sentSms.put(MESSAGE_BODY_FIELD_NAME, messageBody);

    ContentResolver contentResolver = getContentResolver();
    contentResolver.insert(SENT_MSGS_CONTET_PROVIDER, sentSms);
}

Hope this helps!

+6

, , :

<uses-permission android:name="android.permission.WRITE_SMS"/>
0

All Articles