Awdi
Awdi

Reputation: 161

How to send message without composing it?

I am working on application which is activate all your network packages in just one click I know it is possible to dial number that is mentioned in coding in just one click with the help of using ACTION_CALL/ACTION_DIAL and I can activate desire package.

Now there is some packages which are activated with the help of SMS sending like "Sub" to 668. My requirement is when user want to activate such packages he/she didn't write any thing in message body. Message automatically send to desire number which is mentioned in coding and package is activated.

Is there any way to doing this? Or is it possible when I click on button it automatically goes to builtin message body and automatically write "Sub" message and number 123 now its up to user whether he/she want to send or not?

Upvotes: 2

Views: 157

Answers (2)

sahu
sahu

Reputation: 1238

Try this,

Add the permission:

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

Create SmsManager object and send message:

SmsManager myManager = SmsManager.getDefault();
smsManager.sendTextMessage("receiver_number", null, "message_body", null, null);

*Still getting Error or any Exception fell free to ask in the comment.

Hope this will be helpful...thanks

Upvotes: 1

user4571931
user4571931

Reputation:

You can send message without showing composer using SmsManager class. An example of sending sms silently is shown below:

SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage("123456", null, "Test SMS to 123456--> "+mytext, null, null);

You will also need to add the permission:

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

in manifest.

Hope it helps...

Upvotes: 0

Related Questions