I can successfully send an SMS using the following code:
public static void SendSMS(String message, String number) {
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(number, null, message, null, null);
}
However, the message appears in the conversation between me and the person I send it to. Due to the nature of the game I am creating, each player receives a "secret message". I don't want the person running my app to know others' "secret message" by checking the Messaging app.
Is there any way to prevent this behavior? The only way I can think of is by deleting the most recent message in the conversation, but I'm not sure how to do that either, and there's probably an easier way.
Edit for clarity: For my game, only one person is running the app. I am broadcasting a "secret message" to each player in the game. The person running the app should not know what those messages are, so they should not appear in the user's Messaging app.
I have written an answer about sending SMS messages here: Send SMS until it is successful
The sender of the message will not see the message anywhere unless it is explicitly displayed by the app that is running the code somwhow. Atleast that is my experience and I have used it for various occasions.
Though I must admit that I am not sure if that is the case for Android 4.4 as I believe they made some changes regarding SMS handling.
From this site: http://thepu.sh/trends/android-kitkat-far-reaching-update-puts-sms-app-developers-notice/
There can only be one default SMS app at any time
If an app is not chosen as the default SMS app, Google wants the developer to disable the option for that app to send a message. If not disabled, any message sent through this non-default app will not be visible in the user’s default SMS app.`
Related
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.
Sorry if this has been answered but I can't find it anywhere and I've googled for 2 days now for the answer.
I am creating a application that can send a text message from a predefined list of numbers. When I send the messages they are getting stored in the default message application. Is there a way that I can stop this from happening, because if the user send 300 messages, they're going to get 300 names and what was sent in their default message application.
The code I'm using is:
public void sendMessage(String number, ArrayList<String> message) {
String _messageNumber = number;
ArrayList<String> messageText = message;
SmsManager sms = SmsManager.getDefault();
sms.sendMultipartTextMessage(_messageNumber, null, messageText, null, null);
}d
Doesn't seem possible anymore:
"Note: Beginning with Android 4.4 (API level 19), if and only if an app is not selected as the default SMS app, the system automatically writes messages sent using this method to the SMS Provider (the default SMS app is always responsible for writing its sent messages to the SMS Provider)."
Technically default message application doesn't store anything. It just reads messages from database of your mobile. So, it blindly reads all the messages and display it to you. You cant stop the app doing that. So, one way is make your own message database. Just sent the messages to whom ever you want. Later copy whole data to your custom database and delete those messages from default database.
I'm looking for some quick feedback on developing an in-app SMS validation solution as part of my registration process for an Android app. The guy on my team working on the issue seems to be having trouble.
Disclaimer: I am not a developer myself, just have basic coding knowledge.
Basically what should happen is this:
User enters phone number
User selects a "validate number by SMS" button
SMS compose window is launched. Message field is pre-populated with
a validation code. Recipient number pre-populated with a Twilio
phone number connected to my server
Once the user hits send, the SMS window should automatically close
once the message is successfully sent, returning them to my app's
registration process where it will be either waiting to receive a
response from the server or checking at intervals to see if it has
permission (i.e. the phone number was verified) to move to the next
phase of registration.
The problem is with step #4, as my developer has indicated that he doesn't have an object tied to the messaging app, so he is unable to call functions on it... This is where my coding knowledge falls short, so I'd like to hear how others have (or would have) solved this problem. I'm sure that it is solvable.
Thanks!
dont use the text message app intent and just send it within your app
PendingIntent pi = PendingIntent.getActivity(ccc, 0, new Intent(), 0);
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, pi, null);
I've run into the same issue. You should be able to do what you want with code like this (copied from link below):
private void launchSMSActivity(final CharSequence phoneNumber) {
Intent smsIntent = new Intent(Intent.ACTION_VIEW);
smsIntent.setType("vnd.android-dir/mms-sms");
smsIntent.setData(Uri.fromParts("sms", phoneNumber.toString(), null));
smsIntent.putExtra("sms_body", mMessageWithPattern);
smsIntent.putExtra("exit_on_sent", true);
smsIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivityForResult(smsIntent, SEND_SMS);
}
However, there is apparently a bug in 4.3 that causes the message field to appear blank. Hitting send will still send the message. The bug is here: https://code.google.com/p/android/issues/detail?id=58153
Given that, your may choose to send from within the app per tyczj's answer, though keep in mind that doing so will require adding an SMS permission to your app. When users get the permission confirmation dialog it will appear at the top with a notice that it may cost them money. A number of malicious apps have used this permission to run up users' phone bills so many users look at it with suspicion.
You may also choose to only send SMS from within the app on 4.3 devices and use the code above to do it the way you want on all other devices. That doesn't solve the permission problem, unless you publish two APKs - one for pre 4.3 devices without the permission, and one for 4.3 with the permission. This last option is what I'm now considering for my own app.
I have an app which sends normal text SMS to a device to turn it on or off.
I just use the normal sms method:
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);
In hundred of cases the SMS sent by the App do exactly the same as sending SMS manually. However, I have one user who claims, that sending SMS manually has a different effect than sending the SMS from within the app. In fact he claims that with the App the device does not function while sending SMS manually works. What is even stranger is the fact, that the device responds in both cases with a confirmation SMS.
Is that technically possible? Are there any special technical settings that one could change in Android phones when sending SMS? I really can't imagine that there can even be a difference.
many thanks for all your hints
I think you're trying to solve this other way around.
If device sends a confirmation SMS but doesn't function as expected, you probably want the logs from the device.
The actual answer: No. SMS application is using the same API.
Ok guys, I need the brightest minds on this. I am still a novice prorammer for android, but I have been asked to try to creat an app that will allow users to delay the send of their Text Messages.
I.E. when app is running, and I send a message it does not send right away but waits for a minute or two and then asks if you really want to send it; like a verification.
I am not asking for code, but for references which will allow me to read and then construct the code. Is such a service feasible?
Here is what the app needs to access:
SMS service ( to prevent outgoing SMS until ready)
Contact ( for whitelist)
Ringtones on the phone.
thanks for the help.
Rather than override the regular workings of Android's SMS service you should create your own SMS app that sends messages after a timed delay and user approval. The code for sending SMS from Android is trivial:
SmsManager sm = SmsManager.getDefault();
String number = "6508570720";
sm.sendTextMessage(number, null, "Test SMS Message", null, null);
The delay would be only a little bit more difficult and easily handled with a timer. And getting the contacts is also simple.