My app is allowed to send only one SMS per day using the default SMS sender ( which is already present in every android device ), as a result, I need to disable send SMS button once the SMS is sent.
What I am doing currently is, whenever a user clicks on send SMS button, I navigate him to the device default message sender like this,
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromParts("sms", phoneNumber, null));
intent.putExtra("sms_body", message);
baseActivity.startActivity(intent);
I can only navigate the user to default SMS sender and then from there the user can either send SMS or he can cancel sending SMS ( by pressing back button ), now the question is how will I be notified that the SMS is sent? Is there any callback or receiver mechanism which can tell me that the SMS was sent or SMS was canceled by the user?
which is already present in every android device
Not really.
I navigate him to the device default message sender like this,
There is no requirement for an Android device to have an app that responds to ACTION_VIEW for the sms scheme. You will have a better chance with ACTION_SEND, as that is what Google says that you should use.
Even then, there will be devices that lack such an app. For example, not all Android devices are phones.
how will I be notified that the SMS is sent?
You won't. What the user does in response to your ACTION_VIEW (or ACTION_SEND, ACTION_SENDTO, or ACTION_SEND_MULTIPLE) request is up to the user and the user's chosen app.
Is there any callback or receiver mechanism which can tell me that the SMS was sent or SMS was canceled by the user?
Not really. For starters, the user might not choose an SMS client to respond to your Intent. After all, any app can have an activity that responds to your Intent structure. Even if the user chooses an SMS client, there is no guarantee that the app will do anything that allows third parties (like your app) to know about what goes on inside that app.
Many, but not all, SMS clients will update the system supplied Sms content provider with the sent item.
Related
I am trying to send an sms using intent i am able to send the phone number
and the text to send but after running the line
startActivity(smsIntent); the problem is the user have to press the "send" button.
Send it directly using SmsManager. This will require the SEND_SMS permission.
If you delegate the work to a third-party app (e.g., via ACTION_SEND or ACTION_SENDTO), then the user and the other app decide if and when to send the SMS, not you. You are merely suggesting an SMS to send.
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,
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.
Is it possible to receive an email and save it like an sms in android, pretending to be an sms received so a broadcast receiver can intercept it?
There's no malicious intent here.
We have a service where we send alerts to our clients devices(we sell them the devices), but since we have lots of GPRS data available, we would like to use that to send them the alerts whenever something happens related to their assets(cars, boats, etc).
So we send an email to the device via GPRS and our app would intercept it, convert it to an SMS so our app on the device could intercept it(already does that for SMS alerts) and open a map and do some other stuff.
So nothing illegal going on here.
thanks.
I write application which will get data from received SMS. This is data only for application and I dont want to user can read this message. Is possible to consume SMS just after get data from them to prevent user from reading this SMS? Thanks for any help.
You will need a sms receiver see http://davanum.wordpress.com/2007/12/15/android-listen-for-incoming-sms-messages/
Maybe you need also to delete the received sms.
Yes, this is easy to do. See my answer here for how to do this:
SMS receive with no notification
Once you've confirmed that the SMS is one of your special ones, you just need to call abortBroadcast() to stop it going into the user's inbox:
// Stop it being passed to the main Messaging inbox
abortBroadcast();
You should also be aware that the SMS receiver will not intercept SMS messages sent to the user's Google Voice number, as by default those messages will be downloaded over the data connection and displayed by the Google Voice app. If their Google Voice number is configured to forward the SMSs to the phone then those will be handled fine by the SMS receiver.