Can I send an SMS from a service? - android

So i want to write a PoC app for an idea that I have. One of the feature that my app would do is send a text message (and perhaps receive delivery notification). Its not going to be an SMS app. Just a service which might run in the background and sends sms on some particular interval, unattended (of course with user consent).
i remember in some of android api release, Google took the decision that you can only send receive sms if you have selected your app to be "default" sms app ? I don't remember exactly.
So the question is, can my app (as a service) send an sms and receive delivery notification while not being an SMS app ?
Whenever I try to Google this question, I find how to send sms example with SMSManager and the code to send the sms but no where i could find this answer.

So the question is, can my app (as a service) send an sms and receive delivery notification while not being an SMS app ?
Yes. Since KitKat, there has been the concept of a default SMS app, which is what I believe you're referring to.
The main difference in the way SMS are handled as of that version is that only the default SMS app has write access to the Provider, but any other app can still send and receive messages as usual. If your app is not the default, any messages it sends will automatically be written to the Provider by the system.
Furthermore, the SMS_RECEIVED broadcast can no longer be aborted, so you don't have to worry about some other app intercepting incoming messages before your app gets a chance to handle them.

Related

Make the android app as the only sms receiving (inbox and notification) app for a specific sender/originating address

My aim is to show notification and the sms message in inbox of app only from a specific broadcast sender. But using broadcast reciever with Telephony.SMS_RECEIVED receives the sms in the app as well as the main android phone's inbox. So the result is redundant message notifications and backups in phone default inbox as well as app inbox.
Following link shows how to create default sms app for android 4.4 and above for all the senders.
https://android-developers.googleblog.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html
Also, for older versions, abortBroadcast() was used for receiving the sms into a specific app only.
But I want to make an application that notifies and saves the messages only from a particular sender as it is only application specific. Also the message must not go to any other sms inbox apart from app
Is there anyway to do the same ? Or can data sms with specific port number help ?
Usecase: The message to be notified by the app is a user specific message or a broadcast sms. The app has to notify the user of the message even when app is not open,

SMS can be abortBroadcasted on Android 5

It's been a while that I'm surfing the net in order for finding a way to disable the broadcast for incoming sms-text, but mainly it's said that on android 4.4+ you can't do this because it's feature has been removed. But I can show you this is Wrong. In a banking application (targeted android 4.9) in this link
you can find an application which sends out and receives sms without having other apps noticed the transmition of sms. you can download the app here.
Please help me with this issue. how can I Receive sms without having other apps notified ?
They're most likely using data SMS, also known as port-addressed SMS. In fact, a quick, crude unzipping of the APK, and a short perusal of the manifest shows that they have a Receiver registered for the DATA_SMS_RECEIVED action on port 7442.
Data SMS are not handled by the Provider (apart from collation), and only apps listening on that specific port will receive them, so they won't appear in the platform app, or pretty much any other SMS app.
So it's not a matter of the SMS_RECEIVED broadcast being aborted, or the SMS_DELIVER broadcast being intercepted. It's just not regular text messaging.

KitKat - Management of SMS

I'm developing an application that works like an SMS BlackList / WhiteList. It is not a SMS application right now.
The goal is:
If the number is in Blacklist, it prevents the user for receiving / sending sms and it does not appear on his sms applications.
If the number is in Whitelist, the user can do everything he wants.
With some special cases, messages that have been blocked are stored in our database to be send after few hours;
To sum up my app needs to be able to:
Block SMS (before any other app can deal with it, like a popup sms app)
Send SMS
So far, the component works fine with android pre KitKat.
The idea is to deal with broadcast (for received sms) and observers (for sms to send).
By the way, the KitKat SMS handling is mainly different. As I know, we kind of need to be the default sms app to send message.
My questions are:
Do I really need to be the default SMS app to send / observe messages ?
Do I have to implement a kind of basic SMS app or is there another way to send SMS with SMSManager for example ? (http://android-developers.blogspot.fr/2013/10/getting-your-sms-apps-ready-for-kitkat.html)
Do I really need to be the default SMS app to send / observe messages ?
Do I have to implement a kind of basic SMS app or is there another way to send SMS with SMSManager for example ?
No. Any app with the SEND_SMS permission can still send messages using the SmsManager's standard methods, and the writes to the Provider will be taken care of for you, if and only if your app is not the default SMS app. If yours is the default, it is responsible for the writes.
Any app with the RECEIVE_SMS permission can still get the SMS_RECEIVED broadcast and read the message from the Intent. Also, the SMS_RECEIVED broadcast cannot be aborted, starting with KitKat, so there's no real way to block any app listening for that broadcast from receiving incoming texts, even if your app is the default. However, apps that are compliant with the recommended behavior of SMS apps in KitKat or above will disable any processing of incoming messages if they're not the default. That is, if your app is default, other apps shouldn't care about incoming messages.

How to change default app programatically?

I have an app that has device admin rights. My app monitors received SMS's and passes the content through some logic. Can i change the default SMS app to my app programatically . My app checks for spam messages so it needs to read/write/update SMS db. I want a fix for kitkat.
I just noticed that the incoming SMS notification on my app are no longer notifications for new SMS that are received , but instead are "new Hangout message" notifications that are caused by hangouts receiving the incoming SMS. So my app is also not able to receive incoming text messages with SMS_RECEIVED.
Google's Android Developers Blog post about the new SMS API in Kitkat, said that nothing would change for apps using just SMS_RECEIVED and don't try to write the SMS to the SMS Provider.
1 I always believed that the SMS_RECEIVED broadcast is abortable. But the Android 4.4 APIs site says something different: "…when a new SMS arrives by listening for the SMS_RECEIVED_ACTION broadcast, which is a non-abortable broadcast…"
Can i change the default SMS app to my app programatically
Not directly. You can prompt the user to change the default SMS app.
My app checks for spam messages
Repackage your code as a library and license it to SMS clients.
So the Pebble app is also not able to receive incoming text messages with SMS_RECEIVED
Possibly the Pebble app is simply having other problems and is crashing before it notifies the Pebble. Or, possibly the Pebble app is updated for Android 4.4 and, since it knows it cannot stop the Hangouts notification, simply suppresses its own.
Google's Android Developers Blog post about the new SMS API in Kitkat,said that nothing would change for apps using just SMS_RECEIVED and don't try to write the SMS to the SMS Provider
That is not what this blog post says.
I always believed that the SMS_RECEIVED broadcast is abortable
This undocumented, unsupported broadcast had been an ordered, abortable broadcast through Android 4.3. That is no longer the case with Android 4.4, as you can tell by reading the aforementioned blog post:
Note that—beginning with Android 4.4—any attempt by your app to abort the SMS_RECEIVED_ACTION broadcast will be ignored so all apps interested have the chance to receive it.

Check delivery report of sms sent from other application

Can we track the messages sent from other application? I mean, when user send sms by android default sms application (or other sms-managing application), can we track the sms situation and make a notification in our application when sms delivered?
No, this is not possible, unless that other app specifically has an API to support such monitoring.

Categories

Resources