9

I want to send an SMS from my android app. But I don't want its record to be exist in device message view. I am currently using below code.

sendSMS(etsendernumber.getText().toString(), etmessagebody.getText().toString()); 
sendintent = new Intent(Intent.ACTION_VIEW);
sendintent.putExtra("sms_body","");
sendintent.setType("vnd.android-dir/mms-sms");
startActivity(sendintent);

But it is making sent sms record in message view of the device. Can we send a secret sms from android application?

Please advice.

Sanchit Paurush
  • 6,114
  • 17
  • 68
  • 107

2 Answers2

13

Yes, the way you are trying to send SMS is by using the shipped messaging application. So it will always record the sent messages. You must use SmsManager to send the SMS.

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

In this way, your SMS wont be inserted into the list.

Also remember to add this in your manifest

<uses-permission android:name="android.permission.SEND_SMS" />
Royston Pinto
  • 6,681
  • 2
  • 28
  • 46
1

If you use android SMS application to send message then it would save that message in the outbox or sent. What you can do is delete that message from the sms database. After sending sms Delete that message using this:

getContentResolver().delete(Uri.parse("content://sms/outbox"), "address = ? and body = ?", new String[] {etsendernumber.getText().toString(),etmessagebody.getText().toString()});

If msg is in out box

OR

getContentResolver().delete(Uri.parse("content://sms/sent"), "address = ? and body = ?", new String[] {etsendernumber.getText().toString(),etmessagebody.getText().toString()});

If message is in sent items.

AnujMathur_07
  • 2,586
  • 2
  • 18
  • 25