How to change default app programatically? - android

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.

Related

Android - Broadcast SMS intent to other (Biult-in sms app) app in android

I am developing an sms app. Now my app is default sms app on the phone. That means my app is receiving incoming sms first. Now I want to send incoming sms intent to other app (Built-in sms app) from my app pro-grammatically.
Note : I dont want to change default sms app.
My code to send broadcast from my app to built-in sms app --
context.sendBroadcast(intent.setClassName( builtInSmsPackage, "com.android.mms.transaction.SmsReceiverService" )
.setPackage(builtInSmsPackage)
.setAction("android.provider.Telephony.SMS_RECEIVED"));
But built-in sms app cant receive the sms intent which i am sending from my app.
Now my app is default sms app on the phone. That means my app is receiving incoming sms first.
SMS_RECEIVED broadcast order is determined by the priority on the <intent-filters>. SMS_DELIVER is only sent to one receiver, that of the user's chosen default SMS app.
My code to send broadcast from my app to built-in sms app --
First, that is the wrong Intent action. As Mike M. points out, the system will already provide the SMS to all SMS_RECEIVED broadcast receivers. That broadcast usually is ignored by the default SMS client (see the blog post that you claim to have read). The broadcast that is unique for the default SMS app is SMS_DELIVERED.
Second, you do not have rights to send SMS_DELIVER broadcasts. That requires holding the BROADCAST_SMS permission, which cannot be held by ordinary Android SDK apps, to prevent malware authors from doing what you are trying to do. Even with SMS_RECEIVED, I have been recommending that apps ensure that the sender holds BROADCAST_SMS for three years, again to combat malware.
Third, SmsReceiverService is a Service. You cannot send broadcasts to a service. That service may process the SMS_DELIVER broadcast, but it does not receive it.
Now I want to send incoming sms intent to other app
That is not possible on Android 4.4+ through standard Android SDK mechanisms. On Android 4.4+, SMS blocking is a feature of full SMS clients or the OS. It is not a feature that can be added by other apps.

Can I send an SMS from a service?

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.

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.

Abort SMS Intent on Android KitKat

I'm currently developing an application that needs to deal with SMS only if it is an SMS expected by the application (same behaviour as Whatsapp on registration).
I would like to abort the SMS Intent as it is not expected to appear in the SMS box.
My question is : I know that Google changed a lot about SMS behaviour in KitKat, and now, even if my SMS is well parsed by my application, the SMS also appear in SMSBox, even if I call this.abortBroadcast(); in my SMS broadcast receiver. So is there a way to avoid those SMS appearing in SMS box without having to develop a complete SMS application ?
For information, the priority is yet to 1000 (and I tried also with MAX Integer) in Manifest file for this Broadcast Receiver.
Hangouts uses the maximum possible priority (999 per the Intent-Filter docs) and therefore you cannot abort it on <4.4 releases. On 4.4+, only the default SMS app (blog post with details) can make changes to the SMS Provider (i.e., automatically delete the SMS).
You can't stop a message from showing in Default SMS application in kitkat. Checkout following links for details:
https://code.google.com/p/android/issues/detail?id=61684
http://android-developers.blogspot.co.uk/2013/10/getting-your-sms-apps-ready-for-kitkat.html
You can block SMS on Android 4.4 - 4.4.4 using
1)
Using AppsOpps setting
WRITE_SMS permission
Sms will be deleted in 10 seconds with notification about this sms.
As option you can block sound on receiving unwanted sms.
2) Set up your app as default sms app.

Categories

Resources