I'm looking for a sort of trigger in Android, that would let me perform a task whenever a sound is played, so for incoming calls, SMS and e-mail notifications. I did find something like this, but it's only for when the phone is called:
http://developer.android.com/reference/android/telephony/TelephonyManager.html
What I want to achieve with this is sending a bluetooth signal to a bracelet, so it starts vibrating. This would be suited for the hearing impeared or people that work/live in a loud environment who don't carry their phone attached to their bodies.
Calls, SMSes and email are handled by different apps and they have different notifications. Besides calls, you can also get notifications for SMS but not for emails.
SMS broadcast is a private API, meaning that it is not officially supported and can change without notice: Android - SMS Broadcast receiver
Related
Found some SO Q&A about how to send and receive USSD messages (exchanged with the cellular network) on Android. I understand that one needs to register a BroadcastListener to receive USSD message, but have further questions (so far, admittedly theoretical i.e. without having attempted to write code for this).
On Android it is possible (and if so what are the specific things to take care of) so that my application gets to receive the USSD message from cellular network, even though it is not the foreground application, and even though the screen is locked, or when the device is in sleep-mode ?
From what I have read so far, it seem that I'd need a background service that registers the BroadcastListener for USSD message, that can then send a local Notification, to wake up the application which can offer UI for interaction with user. Is that correct ?
Note that the desired behaviour is somewhat analogous to GCM/FCM Notification being used to wake-up an application from sleep (post user interaction responding to the Notification). However, in this case there is no GCM/FCM, but only USSD message from the network.
USSD transaction (Sending and Receiving) is not yet supported on android app, you can follow the issue in google bug tracker: https://issuetracker.google.com/issues/36905980
and also similar question was asked Call (and get the response for) a USSD Code, in the background?
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.
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.
sorry fo my complete ignorance developing an Android.
I'm asking about the feaseability of this pseudocode I would like to implement as native app; let imagine a task that:
when a specific SMS arrive (only those sent from a specific sender number)
possibly (multi-SMS in case of text bigger than 160 chars )
elaborate/format each received SMS:
. save text content on a local db
. print text on a bluetooth printer
. reply to sender with some sort of "ACK" SMS
BTW, what above could be sort of background task, and I would need on foreground a sort of user interface that visualizes received SMS and do some user actions (sending back SMS to sender)
Is all that possible on Android ? Any issue ?
I mean, above all: is possible to "catch" specific SMSs (by example those sent by a specific sender number), living unalterated the usual SMS workflow for ALL other SMSs ?
Sorry for my beginner question and Thanks for your patience
giorgio
www.giorgiorobino.com
Following this link to implement a BroadcastReceiver that will listen for incoming SMS.
Inside your onReceive from your BroadcastReceiver, handle your logic (print/save/..)
It is possible, yes. But not recommended. That being said the way to set this up is to catch the SMS intent, so your app would be started when an SMS is received. Otherwise it would not run at all (as long as you don't have any other interface open). For a code example on the message interception part, see this post. For the database part look up local storage on android phones. Look up on SMS messaging for the reply. Not sure how bluetooth printing would work as I've never done it, but if it's a standard protocol I'm sure there's either built in support or a library for it.
I want my AppWidgetProvider (which is a direct subclass of BroadcastReceiver) to be notified when the user reads a previously unread sms or when he opens the list of missed calls. So far I gound out that it seems to be impossible to get a Intent delivered to the BroadcastReceiver as the actions that open the (sms/phone) activities are not broadcast actions.
Is there another way to let a BroadcastReceiver know when an unread sms is read or the missed calls list is opened?
Short answer: no, sorry.
Neither "unread sms is read" nor "missed calls list is opened" are part of the operating system. They are features of applications. Different implementations of those applications are found on different devices. None have any sort of broadcasts of this nature, AFAIK, mostly because none have any sort of authorized and supported API for developers to use.