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.
In some versions of Android, this permission is turned on by default. In other versions, this permission is turned off by default. To set the app's permission on a device or emulator instance, choose Settings > Apps > SMS Messaging > Permissions, and turn on the SMS permission for the app.
parse("content://sms/inbox"); // List required columns String[] reqCols = new String[]{"_id", "address", "body"}; // Get Content Resolver object, which will deal with Content Provider ContentResolver cr = getContentResolver(); // Fetch Inbox SMS Message from Built-in Content Provider Cursor c = cr.
The following code shows how you can invoke the built-in SMS application to help you send an SMS message: Intent sendIntent = new Intent(Intent. ACTION_VIEW); sendIntent. putExtra("sms_body", "Content of the SMS goes here..."); sendIntent.
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" />
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With