Is it possible to have an app listen for all incoming SMSes and take some action on certain ones?
I read through as many of the similar questions as I could but ended up more confused.
Basically, what I want to do is this:
Every time a new SMS is received, the app checks either the sender or the text, and if a certain string is found shows a message on the screen (Toast, for example).
The app doesn't have a GUI, and if possible I would like to to be running all the time in the background.
If possible, I would also like any SMSes that are shown this way to be deleted before they reach the inbox (or automatically deleted just after).
So, is this at all doable?
Yes this is very possible. With the implementation of a BroadcastListener you could easily be able to determine when an SMS is received by registering the listener to listen to that broadcast. Then in that broadcast receiver code you implement a check for the text of the message. Then do a string compare with what you are looking for and then execute a function.
However; deleting the message from the inbox.. may take a bit of research, i'm not absolutely sure if its possible to delete SMSes programatically, but it wouldn't surprise me if it is included in the API, although, I've never seen it.
Related
I have never developed something in Android before, but now my company has put me on a project which includes android.
My question is this: Is it possible to write an application that runs in the background and waits for triggers (if that is the correct word for it). For instance lets say I want my application to do something as soon as you open your emails or as soon as you get an email. Is there some API that I can use to interact with other applications such as Mail. The application does not have to have any GUI, it will literally just push some information notifications on the mail just received or opened.
I don't require a to technical answer, but rather just yes or no, and indeed yes, where can I get more info on it. Also if it is not possible, is there some workaround to achieve this. I have googled it, but most of the links are how to send an email from your application.
Thanks
EDIT: So it can even be triggered when a notification is received. Then I just want to look at the notification and determine if it is an email?
You could register BroadCastReceiver for the actions that you need to be caught
Seems like GCM for Android only works if there is internet. Wondering whether there are any other methods (maybe via text/call, etc) that could trigger a background service which would send back user's location (via text, etc. or maybe keep it until connection is present)?
My two concerns are:
How much can I do without the user doing anything (or even knowing it's happening... assuming they downloaded the app already and gave appropriate permissions)?
How would I send the data back? (if via text, Reason #1 seems to be a bigger matter)
Here is an alternate solution but it is costly,
Create Broradcast Receiver that listen for incoming SMS.
In any sms with start some predefined word like "START_SERVICE" is arrived then fire the broadcast and start the service you want.
You may use normal SMS scheme or any bulk sms kind of service.
The above scenario doesn't require any INTERNET connection at all.
In a certain situation, I'd like my app to be able to "fake" an incoming SMS on the user's device, as a sort of notification. This would save me money when I'd normally use Twilio to send a text to my users but I know they already have my app. Is there any way to do this? I imagine it would have something to do with Intents and Content Providers but I don't really know where to start.
To clarify:
I'm not new to Android and I do respect all of the normal Notification methods. However, my app will have an opt-in for text messages and I'd like to be able to trigger them for free rather than paying for it. This is for SMS-specific uses and not as a substitute for a normal Notification.
Yes (although I really don't support doing this) it is, in theory possible by creating and broadcasting the proper intent. Specifically, they android.provider.Telephony.SMS_RECEIVED intent will be received by anybody who is listening for SMS messages, including the default SMS application. This will in turn cause the notification to be displayed.
All of that said, I've only ever done this in a custom version of Android from within the system process. I'm really not sure if a generic application can do this (in fact, I kinda doubt it). The other caveat is that you will need to formulate your data into PDU's which represent the binary data format of an SMS message. You can look this up, but it's nontrivial.
A far better approach would be to simply have your application display a notification in the tray, the way well behaved applications are supposed to notify the users of events. Take a look at the Notification class.
If you install the apk named ApiDemos-debug.apk that usually comes installed with your choosen platform for the SDK, you will find an example in
<Api Demos> > App > Notification > IncomingMessage
the complete source for this package is usually under
<SDK root>/samples/android-xx/ApiDemos
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.
I've written a program which uses Broadcast receivers to identify when certain events happen - e.g. new SMS/MMS message, missed call and new gmails.
When the broadcast receivers are triggered I'm setting variables to store the new states that have happened. What I'm looking for is a way to be able to change the setting upon the user seeing these messages - i.e. viewing the SMS, reading the e-mail or viewing the call log - or once they've clicked on the notification. Are there any broadcast receivers to be able to do this, or is there another way?
I ideally want to avoid having to poll for these changes and want to reflect the changes when they happen. Even if polling I'm not sure what I'd look for to see when a user had viewed the call log - for the others I can see how I could use the content provider to handle them.
if i remember well , registerContentObserver(Uri.parse("content://mms-sms"),true,m_MMSObserver)
return something every time something is modified in the database (either adding line or modifying a line) , it should do the trick