2

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?

sahu
  • 1,188
  • 10
  • 19
Awdi
  • 161
  • 1
  • 1
  • 9
  • 1
    I think first answer on following link should work: http://stackoverflow.com/questions/8578689/sending-text-messages-programmatically-in-android – NehaC Jun 29 '15 at 09:04
  • 1
    For second case, you can follow this link http://stackoverflow.com/questions/5788189/action-send-used-to-send-sms – justHooman Jun 29 '15 at 09:06
  • Using SMS manager you can send sms without invoking SMS application and for call you may use ACTION_CALL to invoke the call intent. – Atmaram Jun 29 '15 at 09:13

2 Answers2

1

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

sahu
  • 1,188
  • 10
  • 19
  • if i am not wrong this will open new message body but i want to use Built-in SMS application. Is this work in Intent sendIntent = new Intent(Intent.ACTION_VIEW) ? – Awdi Jun 29 '15 at 10:06
  • can you please tell me the complete code with layout file? – Awdi Jul 01 '15 at 07:06
0

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

  • if i am not wrong this will open new message body but i want to use Built-in SMS application. – Awdi Jun 29 '15 at 10:07
  • This will send the sms from your device without opening the SMS application or message composer. –  Jun 29 '15 at 12:45
  • can you please tell me complete code? Thanks in advanced – Awdi Jun 29 '15 at 18:05