I'm a UG student.....I'm creating an android application as my project work
My application is......setting an event in calender....my app retrieves start time and end time from calender and silences the calls and messages received during that time period and sends sms to calls and messages automatically if required....i have coded till the silencing calls and messages..and I have kept the check boxes to reply for calls and to reply for sms but I'm not understanding how to send messages if the user selects the check boxes
you can store the user preferences in a database (or shared preferences, or any other way), on the basis of the checkbox
check for the preferences, whenever an event for which you could send a message occurs and send a message programmatically with the following code
SmsManager sms = SmsManager.getDefault();
try
{
sms.sendTextMessage(phoneNumber, null, messageText, null, null);
}
catch(IllegalArgumentException e)
{
}
Related
How can I send sms without save in inbox or sent folders in android?
when I using this code, the message save in sent folder:
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNumber, null, messageBody, null, null);
but I want to send message in background.
Is your app running in android 4.4 and above?
Starting from Android 4.4, you cannot send the sms without showing in the sentbox.
Outlined at https://developer.android.com/about/versions/android-4.4.html#SMS you can see the changes.
SMS Provider The Telephony content provider (the "SMS Provider") allows apps to read and write SMS and MMS messages on the device. It includes tables for SMS and MMS messages received, drafted, sent, pending, and more.
Beginning with Android 4.4, the system settings allow users to select a "default SMS app." Once selected, only the default SMS app is able to write to the SMS Provider and only the default SMS app receives the SMS_DELIVER_ACTION broadcast when the user receives an SMS or the WAP_PUSH_DELIVER_ACTION broadcast when the user receives an MMS. The default SMS app is responsible for writing details to the SMS Provider when it receives or sends a new message.
Other apps that are not selected as the default SMS app can only read the SMS Provider, but may also be notified when a new SMS arrives by listening for the SMS_RECEIVED_ACTION broadcast, which is a non-abortable broadcast that may be delivered to multiple apps. This broadcast is intended for apps that---while not selected as the default SMS app---need to read special incoming messages such as to perform phone number verification.
For more information, read the blog post, Getting Your SMS Apps Ready for KitKat.http://android-developers.blogspot.my/2013/10/getting-your-sms-apps-ready-for-kitkat.html
I have to create an app which has some Mobile numbers in its database. It has to send SMS to everyone one of the number in the database at 12:00 AM everyday. I know how to add the numbers in database. But I don't know how to send scheduled messages for all those numbers. Any helps please?
Use alarmmanager to schedual a call to a method which fetch no. from your database and send your desired message to that number.
From android docs:
AlarmManager:This class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future. When an alarm goes off, the Intent that had been registered for it is broadcast by the system, automatically starting the target application if it is not already running.
Use SmsManager to send sms
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo, null, message, null, null);
And use alarm manager to do it every day
Look at this tutorial for more detail:
http://www.tutorialspoint.com/android/android_sending_sms.htm
http://javatechig.com/android/repeat-alarm-example-in-android
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 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.`
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.