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

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? :)

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

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.

Related

Sending messages between Android Wear & Mobile?

I'm writing an app which sends a predefined message to a predefined number. It then gets the response and displays this to the user. I've got the mobile side working, and I am now working on the Wear app, however have become a little stuck as to how to do it.
I've managed to send the message from the Wear device by implementing a listener on the mobile app, which then triggers the activity to send a message. What I can't figure out how to do, is that the response the app gets and send it back to the Wear device.
Looking here:https://developer.android.com/training/wearables/data-layer/index.html
I have used the MessagesAPI for sending the message, however unsure what to use if I want to receive a message. Does anyone know what the best way to do this would be? My initial instinct says I'm going to have to ditch the messagesApi and use the Data one?
You should send the response the same way you used to send the first message, but this time the wearable will be listening for messages (usually in your WearableListenerService).
Take a look at this: https://github.com/heinrisch/talkclient
Either you can use the library or look at the code. I would look at the code, its quite easy to follow.
It sounds like you can use either data or message api, depending on your needs. To receive a message you either have the app active and get it though a listener, or you create a service.

capture the Sms exactly before being sent

Iā€™m trying to develop an application to do some manipulation (compression and security matters) on the outgoing Sms regardless of the composer application. The main challenge is that I cannot capture the Sms exactly before being sent. For instance the user compose the message body using Go Sms Pro and when the send button is pressed , right before the sms is actually sent we capture it and do the compression and security matters on .
Any solution or replacement idea appreciated.
Starting with KitKat, the SMS content provider has been opened up (finally): http://developer.android.com/about/versions/android-4.4.html
To make this work with previous versions of android, you could set up a content observer to watch content://sms/, query the appropriate tables in that database, and then do whatever you like to erase the message before it goes out. This is just a thought mind you, but whatever you do will likely involve using this method.
This is not possible, short of via your own custom build of the Android OS. You have no ability to intercept, let alone modify, the calls from an arbitrary app via SmsManager to the OS to send an SMS message.

Android 4.4 sent SMS Stored in Inbox

In Android 4.4, My App is not an SMS App but it need to send SMS(multiple times).
The thing is that the Sent SMS will be stored in Default SMS App(Hangouts).
It would spam/annoy users a lots. I would like the SMS actions are transparent/silently with End-Users.
AFAIK, we may prevent this by setting my App at the moment I send the SMS & change back later.
But this is not really an option since end-user flow become complicated & may lead to confusion. another reason is Default SMS App may lose the System Broadcast when my App was set as Default SMS App.
Is there complete solution on this?
Thank you for you support.
If i am not wrong.. you want to send sms without storing in default sentitems list..????
The task you mentioning is possible without any confusion in the flow...
This can be done by setting the sentIndent in smsmanager to null.
public final void sendTextMessage (String destinationAddress, String scAddress, String text, PendingIntent sentIntent, PendingIntent deliveryIntent)
This will suppress the sentintent thereby avoiding to store in the default sent items...
There is also a previously discussed question regarding this topic in stackoverflow..
How to send SMS from the Android app without making its record in device SMS view?
Check it out...
If you could share the code u use for sending message.. It would be more easy to help for others...

Android: Is there an onSMSSend event?

I've got an idea for an Android Application, however I am unsure if it would work. Essentially what I want to do is "intercept" all text messages sent from any SMS App and make modifications to them.
For example, say I write out the following SMS:
Hi {Name}, how are you today? Can you tell {Boss} I'll be 15 minutes late today.
The onSMSSend function in my application(assuming it is currently running in the background) would then be able to edit the content of the message(Eg. Replacing variables with ones defined in the application), and then send it on to the recipient.
Is Android able to provide this functionality?
No it is not. Android may be able to inform you after an SMS was send. But there is no way to intercept a message that should be sent and apply changes to it on a non rooted phone.
What you could do is to write a new messaging App that allows the user to type a message, choose a number and send the message. Now you have full control over the message that is send but building a replacement for the sms app is a fair amount of work.

Problem in getting Contact Info

I m working on application in which i have to send all contacts from Android mobile to other mobile through SMS. I don't have any problem in getting contact information but when I send those Contacts after few messages there is Alert Window pop up saying "A large number of message have being send" and ask if you want to send or not.
I am testing this application on HTC Hero.
Is this problem is for specific mobiles or for all?
I don't know what should i do to avoid this window because I cant get SMS Sent event.
Please help me with any ideas that i can implement........
The alert window doesn't appear after a "few messages" ā€” the limit is 100 messages, per application, per hour, before that warning appears.
If you really must use SMS, then I would suggest bundling multiple contacts together or batching the sends over time ā€” short of rooting the phone, there is no way to get around this (sensible and useful) warning.
See also: http://groups.google.com/group/android-developers/browse_thread/thread/587f0d3a03ced88a
I think this a security check back to inform the user that an app is wasting a lot of money through sending a lot of SMS messages. If the use case of your app is valid you have to convince the user that sending all this messages is necessary and that he has to click the send button.
I hope and thinkg that there is no way to program around this because this a very sensible thing to do for a phone.

Categories

Resources