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
Related
I'm sending 5 messages via android SmsManager and need to check the delivery order. Are the SMSs that are sent in an order delivered in the same order or not. If not, what is the order of delivery?
I think I can do it by BroadcastReceiver to check the delivery but how about the order?
Thanks
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)
{
}
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.
I have an application which sends an auto SMS when I receive an SMS, or missed cal etc. So, if the same application is there in the opposite person's phone, then the the process of sending SMS continues, which should not happen. How to avoid this?
In fact, how to detect an SMS, which is sent by user or auto replied?
Please try to explain programmatically as clearly as possible..
SmsManager sm = SmsManager.getDefault();
sm.sendTextMessage(phoneno, null,"sam", null, null);