last day (14 days later) » 

7:47 AM
0
A: send sms on selected contact in android

user3811114You need to use SmsManager for sending sms. Below is code for your reference : SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage("phoneNo", null, "sms message", null, null); Apply this code on your send message button click listener.

 
07-14 18:04:48.683: E/AndroidRuntime(26749): FATAL EXCEPTION: main 07-14 18:04:48.683: E/AndroidRuntime(26749): java.lang.NullPointerException 07-14 18:04:48.683: E/AndroidRuntime(26749): at com.android.internal.telephony.gsm.SmsMessage.getSubmitPduHead(SmsMessage.java:6‌​‌​60)
got this exception
 
have you added below permission in your manifest <uses-permission android:name="android.permission.SEND_SMS" /> & put phone number & message. If you still get error show your whole logcat.
 
done message have been send. now how can i send message from selected contact from my contact list. I have contact list when i select contact from that list the message will sent automatically on these numbers
thank you so much user3811114 for your quick reply please help me sir i want to send message on selected contact from my contacts
 
When you get correct answer so you need to upvote to that user this is how stackoverflow works. You need to use arraylist for your requirement. Your arraylist will be having mobile numbers & pass that arraylist using foreach loop to sendMessage function for every number.
 
sir i need your help
 
7:49 AM
ya tell me where you got stuck
 
as u said You need to use arraylist for your requirement. Your arraylist will be having mobile numbers & pass that arraylist using foreach loop to sendMessage function for every number
i have make an array list like this
String toNumbers = "";
ArrayList<String> numbersArrayList;// your phone numbers here
for ( String number : numbersArrayList)
{
toNumbers = toNumbers + number + ";"//separating numbers with semicolon
}
toNumbers = toNumbers.subString(0, toNumbers.length - 1);
have u got my point what i am trying to do
i have already red this link mkyong.com/android/how-to-send-sms-message-in-android
now i am able to send message like built in message body and number, now i want i send message on multiple selected contacts from contact list
 
Let me know one thing.
 
sure sir
 
suppose you have 3 numbers & you want to send sms to these 3 numbers. Is this your requirement???
 
no i have 100 contacts on my contact list and i want to send message on selected contact
is there any way whom i send a snap shots so thats more clear for you what i want to do
can i have your email address so i will send snap shots
 
7:59 AM
Yes i got your point. We are just considering your scenario for small case, then you can extend it
You mean suppose out of 100 you selected 30 contacts. So you want to send messages to those 30 contacts. right???
Ali as per my understanding I'm posting code that you need. I am pretty sure this will solve your problem.
send me your email address so I can email you source code
			ArrayList<String> arrayList = new ArrayList<String>();
			arrayList.add("9912345678");
			arrayList.add("9912345478");
			arrayList.add("9913345678");

			SmsManager smsManager = SmsManager.getDefault();

			for (String string : arrayList) {
				smsManager.sendTextMessage(string, null, "type your message over here", null, null);
			}
Check this posted code
In above code sendTextMessage() method will be called thrice because my arraylist containing 3 contacts to those sms will be sent.
Let me know if you have any difficulty
 
can i have your email address
o let me check sir this scenario
 
vvbhandare@rediffmail.com
send me yours emailaddress
 
8:19 AM
aliashiqr1130@gmail.com
 
8:39 AM
Have u received my mail
 

last day (14 days later) »