Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send SMS message on android device in the background?

Tags:

android

sms

in my app i need to be able to send a text message in a background, without users intervention. I am using SmsManager (code below) to accomplish that. It does send a message but the popup asking me to choose a delivery method still shows up (even after the message is sent). I do have Google Voice installed thus the popup. Is there a way for me to avoid displaying this popup while sending text message? Perhaps i shall use a different method?

Thanks!

SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage(number, null, message, null, null);

Update: so just to see what will happen i selected a default delivery method being "text message" and check the box saying use this as default. Now when i send the message using the code above it sends it in the background but it also bring up the empty form to send a message to :| How do i get rid of this? :)

like image 629
android-developer Avatar asked Apr 15 '11 01:04

android-developer


People also ask

Can Android emulator send SMS?

Run your app. Enter a phone number (or the emulator port number if using emulators), and enter the message to send. Tap the messaging icon to send the message. After running the app, choose Settings > Apps > SMS Messaging > Permissions and turn off SMS permission for the app.


2 Answers

restored the device and problem was gone, so must've been a third party app causing the send new message form, its all good now, sms is being send in a background. thanks for your help all...

like image 83
android-developer Avatar answered Nov 15 '22 02:11

android-developer


I tested that and didn't have that problem. I have Google Voice installed but only use it for voicemail on my main line so maybe thats it. Can I assume you have a separate Voice number? I think this is just an issue of Android not knowing which number to send the text from so you will have to pick a default the first time. Is there the option to set it as the default method? If your intention is the send this text secretly then maybe you might want to rethink your intentions for doing so.

like image 25
Dan Avatar answered Nov 15 '22 04:11

Dan