Add text message entry into native messaging application in Android - android

In my application I am trying to send a text message with the following code and it's working fine. But when I check the native messaging application the message that i have sent from my application is not in the native messaging application. Am I missing something or is their any other code that I have to write, so that the text that I'll send from the application also get's updated in the native messaging application. The code that I am using is:
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(number, null, message, null, null);
Please let me know how can I create an entry in the native messaging application of this message.
Thanks..

Related

send bulk sms on android sms app using api from another provider

I have a bulk sms site http://esmsafrica.com now I am building a sms app that will use the same API so that users registered on the site can still view there balance and send sms, I understand to use default smsmanager for android is below code, I have also searched on android developer page yet nothing seems to help, can someone let me know how to go about this, would I need to import any code from my site? I believe it should look like below code. I have a valid API code, username and password.
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, senderID, message, sentPI, deliveredPI);

Programmatically Send SMS without it showing in Messaging App

Is there a way to programmatically send sms messages without them showing in the Messaging app?
I am using the following code to send SMS:
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("number", null, "message", null, null);
And the messages are showing in the default Messaging app aswell as Google Hangouts. For my application it would be ideal for the messages not to show up, as they are simply sending code to a GSM module, and they just fill up the users Messaging app.
If you aren't sending real texts, you should probably send a port based SMS which won't be added to the messaging DB. But if you can't, you need to delete it from the sms content resolver.
ctx.getContentResolver().delete(Uri.parse("content://sms/inbox"), {"body"}, messageBodyToDelete);

How to send SMS from the Android app without making its record in device SMS view?

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.
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.

Android: How to send SMS to email account

The stock Android text messaging app allows you to send SMS to an email account instead of a phone number. How is this done? I tried the following code and it failed.
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage("myaccount#gmail.com", null, textMsg, sentPI, null);
This other question seems to be related How to send SMS message reply to email address?
... but the accepted answer says
Each cell carrier has a specific SMS number that you can send a text message to in a certain format. This is called a "SMS Gateway".
I want to send to my gmail account, not to AT&T.
Sorry, seems I misread the answer. Looks like my carrier (AT&T) will send the email for me. What puzzles me is how an app could work for different carriers?

SmsManager with Email Address as Destination - NullPointerException

My cellphone carrier offers an sms-email gateway. This is done simply by entering the email address as the SMS message's destination. The email is delivered as 5555555555#mycarrier.com
I am attempting to use this with my new Android device. The standard android messaging application converts all messages with an email address as the destination to "MMS" and attempts to send them as data - not what I want to do.
Attempting with android.telephony.SmsManager:
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage("address#example.com", null, "Message body here", null, null);
This throws the following exception:
Caused by: java.lang.NullPointerException
at com.android.internal.telephony.gsm.SmsMessage.getSubmitPduHead(SmsMessage.java:595)
at com.android.internal.telephony.gsm.SmsMessage.getSubmitPdu(SmsMessage.java:295)
at android.telephony.SmsMessage.getSubmitPdu(SmsMessage.java:599)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:228)
at android.telephony.SmsManager.sendTextMessage(SmsManager.java:107)
I've looked at this project, android-sms-email, which attempts to do the same thing. It also crashes in the same fashion when configured for my carrier.
This does not seem like the desired behaviour and I assume it is an Android bug (some bug reports hint at the issue). I've experimented a bit and can see that appending any number and some symbols to the email address do not cause the same failure but the message is not delivered either.
I've also tried using SmsManager.sendMultipartTextMessage but this runs into the same problem within SmsMessage.getSubmitPduHead.
Again:
SmsManager manager = SmsManager.getDefault();
// Works
manager.sendTextMessage("15555555555", null, "Message body here", null, null);
// Fails
manager.sendTextMessage("address#example.com", null, "Message body here", null, null);
Tested on an HTC Desire Z - Android v2.2
Please check this articles.
Programatically send SMS to email using Verizon Motorola Droid on Android
How to send SMS message reply to email address?
You should know the SMS gateway number of the carrier and make a message like this:
SmsManager manager = SmsManager.getDefault();
manager.sendTextMessage("6425", null, "username#domain.com (Subject) message text", null, null);
Verizon wireless-> 6425, AT&T mobility -> 121 111
I've issued a bug report: http://code.google.com/p/android/issues/detail?id=16934

Categories

Resources