问题描述
现在我能选择从我在我的手机通讯录只有一个接触,我想在我的联系人名单发送短信更多的人,我怎么能发送。
现在,我不能在手机上没有编辑文本,即使在手动也从联系人列表也越来越添加更多联系人。
我想在我的联系人名单发送更多的联系号码发送sms.what我可以做
公共类SendSMSActivity延伸活动{
按钮buttonSend,搞定;
私有静态最终诠释CONTACT_PICKER_RESULT = 1001;
PHONENO的EditText;
的EditText textSMS;
INT columnIndex_number;
静态字符串stringNumber;
串短信;
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.about);
PHONENO =(EditText上)findViewById(R.id.editText1);
textSMS =(EditText上)findViewById(R.id.editText2);
得到=(按钮)findViewById(R.id.button1);
get.setOnClickListener(新OnClickListener(){
@覆盖
公共无效的onClick(视图v){
// TODO自动生成方法存根
意图contactPickerIntent =新意图(Intent.ACTION_PICK,
Contacts.CONTENT_URI);
startActivityForResult(contactPickerIntent,CONTACT_PICKER_RESULT);
}
}); 意向intent1 = getIntent(); //得到previously创建意图
最后弦乐firstKeyName = intent1.getStringExtra(firstKeyName);
textSMS.setText(firstKeyName); buttonSend =(按钮)findViewById(R.id.button2);
buttonSend.setOnClickListener(新OnClickListener(){ @覆盖
公共无效的onClick(视图v){
尝试{ 。字符串短信= textSMS.getText()的toString()修剪();
Toast.makeText(getApplicationContext(),phoneNo.getText()。的toString()+ firstKeyName,
Toast.LENGTH_LONG).show();
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo.getText()的toString(),空,firstKeyName,NULL,NULL);
Toast.makeText(getApplicationContext(),短信发送!
Toast.LENGTH_LONG).show(); }赶上(例外五){
Toast.makeText(getApplicationContext(),
短信faild,请稍后重试!,
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
完();
}
});
} @覆盖
保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
如果(结果code == RESULT_OK){
开关(要求code){
案例CONTACT_PICKER_RESULT: 光标光标= NULL;
串phoneNumber的=;
清单<串GT; allNumbers =新的ArrayList<串GT;();
INT phoneIdx = 0;
尝试{
乌里结果= data.getData();
字符串ID = result.getLastPathSegment();
光标= getContentResolver()查询(Phone.CONTENT_URI,空,Phone.CONTACT_ID +=?,新的String [] {ID},NULL);
phoneIdx = cursor.getColumnIndex(Phone.DATA);
如果(cursor.moveToFirst()){
而(cursor.isAfterLast()== FALSE){
phoneNumber的= cursor.getString(phoneIdx);
allNumbers.add(phoneNumber的);
phoneNo.setText(cursor.getString(phoneIdx)); cursor.moveToNext();
}
}其他{
//没有结果的行动
}
}赶上(例外五){
//错误操作
} {最后
如果(指针!= NULL){
cursor.close();
}
}
打破;
}
}其他{
//活动结果错误操作
}
}
}
Logcaterror其显示:
14 06-07:06:05.546:E / AndroidRuntime(780):致命异常:主要
06-07 14:06:05.546:E / AndroidRuntime(780):android.content.ActivityNotFoundException:无法找到明确的活动类{com.example.jsonandroid / com.example.jsonandroid.ContactActivity};有你宣布你的AndroidManifest.xml这个活动?
06-07 14:06:05.546:E / AndroidRuntime(780):在android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.app.Activity.startActivityForResult(Activity.java:3370)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.app.Activity.startActivityForResult(Activity.java:3331)
06-07 14:06:05.546:E / AndroidRuntime(780):在com.example.jsonandroid.SendSMSActivity $ 1.onClick(SendSMSActivity.java:42)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.view.View.performClick(View.java:4202)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.view.View $ PerformClick.run(View.java:17340)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.os.Handler.handleCallback(Handler.java:725)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.os.Handler.dispatchMessage(Handler.java:92)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.os.Looper.loop(Looper.java:137)
06-07 14:06:05.546:E / AndroidRuntime(780):在android.app.ActivityThread.main(ActivityThread.java:5039)
06-07 14:06:05.546:E / AndroidRuntime(780):在java.lang.reflect.Method.invokeNative(本机方法)
06-07 14:06:05.546:E / AndroidRuntime(780):在java.lang.reflect.Method.invoke(Method.java:511)
06-07 14:06:05.546:E / AndroidRuntime(780):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793)
06-07 14:06:05.546:E / AndroidRuntime(780):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-07 14:06:05.546:E / AndroidRuntime(780):在dalvik.system.NativeStart.main(本机方法)
您可以从联系人列表中的所有联系人,并在列表中显示出来。您可以使用复选框选择联系人,然后单击按钮。导航到SendMessage函数的活动,并输入短信内容和发送消息
我觉得这是对付复选框一个更好的方式。对于复选框得到选中的项目我也跟着下面的链接。
的
您也可以获取你只需要列。下面取出所有列这是不好的。
光标手机= cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,NULL,NULL,NULL,NULL);
get.xml
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =match_parent
机器人:layout_height =match_parent
工具:上下文=MainActivity。>< ListView控件
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_above =@ + ID /按钮1
机器人:ID =@ + ID / LV/>
<按钮
机器人:ID =@ + ID /按钮1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentBottom =真
机器人:layout_alignParentLeft =真
机器人:layout_marginLeft =44dp
机器人:文字=发送/> < / RelativeLayout的>
MainActivity.java
公共类MainActivity扩展活动实现OnItemClickListener {
的ArrayList<串GT;名1 =新的ArrayList<串GT;();
ArrayList的<串GT; phno1 =新的ArrayList<串GT;();
ArrayList的<串GT; phno0 =新的ArrayList<串GT;();
MyAdapter马;
按钮显示,加入;
@覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.get);
getAllCallLogs(this.getContentResolver());
LV的ListView =(ListView控件)findViewById(R.id.lv);
MA =新MyAdapter();
lv.setAdapter(MA);
lv.setOnItemClickListener(本);
lv.setItemsCanFocus(假);
lv.setTextFilterEnabled(真);
//添加
添加=(按钮)findViewById(R.id.button1);
add.setOnClickListener(新OnClickListener()
{ @覆盖
公共无效的onClick(视图v){
StringBuilder的checkedcontacts =新的StringBuilder();
的System.out.println(..............+ ma.mCheckStates.size());
的for(int i = 0; I< name1.size();我++) {
如果(ma.mCheckStates.get(我)==真)
{
phno0.add(phno1.get(ⅰ)的ToString());
checkedcontacts.append(name1.get(ⅰ)的ToString());
checkedcontacts.append(\\ n); }
其他
{
的System.out.println(..未签......+ name1.get(I)的ToString());
}
}
Toast.makeText(MainActivity.this,checkedcontacts,1000).show();
意向意图=新意图(新意图(MainActivity.this,SendMessage.class));
intent.putStringArrayListExtra(名,phno0);
startActivity(意向); }
});
}@覆盖
公共无效onItemClick(适配器视图<>为arg0,ARG1观,诠释ARG2,长ARG3){
// TODO自动生成方法存根
ma.toggle(ARG2);
}公共无效getAllCallLogs(ContentResolver的CR){ 光标手机= cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,NULL,NULL,NULL,NULL);
而(phones.moveToNext())
{
字符串名称= phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
串phoneNumber的= phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
的System.out.println(..................+ phoneNumber的);
name1.add(名);
phno1.add(phoneNumber的);
} phones.close();
}
类MyAdapter扩展了BaseAdapter实现CompoundButton.OnCheckedChangeListener
{私人SparseBooleanArray mCheckStates;
LayoutInflater mInflater;
TextView的TV1,电视;
复选框CB;
MyAdapter()
{
mCheckStates =新SparseBooleanArray(name1.size());
mInflater =(LayoutInflater)MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@覆盖
公众诠释的getCount(){
// TODO自动生成方法存根
返回name1.size();
} @覆盖
公共对象的getItem(INT位置){
// TODO自动生成方法存根
返回的位置;
} @覆盖
众长getItemId(INT位置){
// TODO自动生成方法存根 返回0;
} @覆盖
公共查看getView(最终诠释的立场,观点convertView,父母的ViewGroup){
// TODO自动生成方法存根
查看VI = convertView;
如果(convertView == NULL)
VI = mInflater.inflate(R.layout.row,NULL);
TextView的电视=(TextView中)vi.findViewById(R.id.textView1);
TV1 =(TextView中)vi.findViewById(R.id.textView2);
CB =(复选框)vi.findViewById(R.id.checkBox1);
tv.setText(姓名:+ name1.get(位置));
tv1.setText(电话号码:+ phno1.get(位置));
cb.setTag(位置);
cb.setChecked(mCheckStates.get(位置,FALSE));
cb.setOnCheckedChangeListener(本); 返回VI;
}
公共布尔器isChecked(INT位置){
返回mCheckStates.get(位置,FALSE);
} 公共无效setChecked(INT位置,布尔器isChecked){
mCheckStates.put(位置,器isChecked);
} 公共无效切换(INT位置){
setChecked(位置,器isChecked(位置)!);
}
@覆盖
公共无效onCheckedChanged(CompoundButton buttonView,
布尔器isChecked){
// TODO自动生成方法存根 mCheckStates.put((整数)buttonView.getTag(),器isChecked);
}
}
}
SendMessage.java
公共类的SendMessage扩展了活动{ED1的EditText,ED2;
ArrayList的<串GT; sendlist =新的ArrayList<串GT;();
按钮B1;
@覆盖
保护无效的onCreate(捆绑savedInstanceState){
// TODO自动生成方法存根
super.onCreate(savedInstanceState);
的setContentView(R.layout.sendmessage);
ED1 =(EditText上)findViewById(R.id.editText1);
ED2 =(EditText上)findViewById(R.id.editText2);
捆绑额外= getIntent()getExtras()。
如果(临时演员!= NULL)
{
sendlist = extras.getStringArrayList(名称);
如果(sendlist!= NULL)
{
的for(int i = 0; I< sendlist.size();我++)
{
ed1.append(sendlist.get(ⅰ)的ToString());
ed1.append(;);
}
}
}
其他
{
Toast.makeText(getApplicationContext(),空,
Toast.LENGTH_LONG).show();
}
B1 =(按钮)findViewById(R.id.button1);
b1.setOnClickListener(新OnClickListener()
{ @覆盖
公共无效的onClick(视图v){
// TODO自动生成方法存根
的for(int i = 0; I< sendlist.size();我++)
{ 如果(ed2.getText()长度()方式> 0)
{
尝试{
SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(sendlist.get(I)的ToString(),空,ed2.getText()的toString(),NULL,NULL); Toast.makeText(getApplicationContext(),短信发送!
Toast.LENGTH_LONG).show();
}赶上(例外五){
Toast.makeText(getApplicationContext(),
短信faild,请稍后重试!,
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
} } });
}
}
sendmessage.xml
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent><的EditText
机器人:ID =@ + ID / editText1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_alignParentRight =真
机器人:layout_alignParentTop =真
机器人:layout_marginTop =18dp
机器人:EMS =10> < requestFocus的/>
< /&的EditText GT;<的EditText
机器人:ID =@ + ID / editText2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =200dp
机器人:layout_alignParentLeft =真
机器人:layout_alignParentRight =真
机器人:layout_below =@ + ID / editText1
机器人:layout_marginTop =62dp
机器人:EMS =10/><的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignTop =@ + ID / editText1
机器人:layout_centerHorizontal =真
机器人:文字=电话号码/><的TextView
机器人:ID =@ + ID / textView2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / editText1
机器人:layout_centerHorizontal =真
机器人:layout_marginTop =37dp
机器人:文字=消息/><按钮
机器人:ID =@ + ID /按钮1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView2
机器人:layout_alignParentBottom =真
机器人:文字=发送/>< / RelativeLayout的>
您需要添加这两种权限
<使用许可权的android:NAME =android.permission.READ_CONTACTS/>
<使用许可权的android:NAME =android.permission.SEND_SMS/>
编辑:
先打开SendMessage的活动。点击旁边editext1获取按钮。导航到MainActivity其中显示所有联系人,并选择使用复选框。点击发送将完成actiivty和retunn短信活动。你可以看到所选的联系人在editext 1,其余是一样的。
我已经使用startActivity的结果。这比我能做些什么来帮助你。请修改相应的相同。
公共类的SendMessage扩展了活动{ED1的EditText,ED2;
静态INT结果code = 12;
ArrayList的<串GT; sendlist =新的ArrayList<串GT;();
按钮B1,B2;
@覆盖
保护无效的onCreate(捆绑savedInstanceState){
// TODO自动生成方法存根
super.onCreate(savedInstanceState);
的setContentView(R.layout.sendmessage);
B2 =(按钮)findViewById(R.id.button2);
ED1 =(EditText上)findViewById(R.id.editText1);
ED2 =(EditText上)findViewById(R.id.editText2);
B1 =(按钮)findViewById(R.id.button1);
b2.setOnClickListener(新OnClickListener()
{ @覆盖
公共无效的onClick(视图v){
// TODO自动生成方法存根
意图I =新意图(SendMessage.this,MainActivity.class);
startActivityForResult(I,结果code);
} }); b1.setOnClickListener(新OnClickListener()
{ @覆盖
公共无效的onClick(视图v){
// TODO自动生成方法存根
的for(int i = 0; I< sendlist.size();我++)
{ 如果(ed2.getText()长度()方式> 0)
{
尝试{
SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(sendlist.get(I)的ToString(),空,ed2.getText()的toString(),NULL,NULL); Toast.makeText(getApplicationContext(),短信发送!
Toast.LENGTH_LONG).show();
}赶上(例外五){
Toast.makeText(getApplicationContext(),
短信faild,请稍后重试!,
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
} } });
}
保护无效的onActivityResult(INT申请code,INT结果code,意图数据){ 如果(要求code ==结果code){ 如果(结果code == RESULT_OK){
sendlist = data.getStringArrayListExtra(名称);
如果(sendlist!= NULL)
{
的for(int i = 0; I< sendlist.size();我++)
{
ed1.append(sendlist.get(ⅰ)的ToString());
ed1.append(;);
} }
如果(结果code == RESULT_CANCELED){ }
}
}
}
}< XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent><的EditText
机器人:ID =@ + ID / editText1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_alignParentRight =真
机器人:layout_alignParentTop =真
机器人:layout_marginTop =18dp
机器人:EMS =10> < requestFocus的/>
< /&的EditText GT;<的EditText
机器人:ID =@ + ID / editText2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =200dp
机器人:layout_alignParentLeft =真
机器人:layout_alignParentRight =真
机器人:layout_below =@ + ID / editText1
机器人:layout_marginTop =62dp
机器人:EMS =10/><的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignTop =@ + ID / editText1
机器人:layout_centerHorizontal =真
机器人:文字=电话号码/><的TextView
机器人:ID =@ + ID / textView2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / editText1
机器人:layout_centerHorizontal =真
机器人:layout_marginTop =37dp
机器人:文字=消息/><按钮
机器人:ID =@ + ID /按钮1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView2
机器人:layout_alignParentBottom =真
机器人:文字=发送/><按钮
机器人:ID =@ + ID /按钮2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBaseline =@ + ID / textView2
机器人:layout_alignBottom =@ + ID / textView2
机器人:layout_alignParentRight =真
机器人:文字=获取/> < / RelativeLayout的>
MainActivity
公共类MainActivity扩展活动实现OnItemClickListener {
ArrayList的<串GT;名1 =新的ArrayList<串GT;();
ArrayList的<串GT; phno1 =新的ArrayList<串GT;();
ArrayList的<串GT; phno0 =新的ArrayList<串GT;();
MyAdapter马;
按钮发送;
@覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
的setContentView(R.layout.get);
getAllCallLogs(this.getContentResolver());
LV的ListView =(ListView控件)findViewById(R.id.lv);
MA =新MyAdapter();
lv.setAdapter(MA);
lv.setOnItemClickListener(本);
lv.setItemsCanFocus(假);
lv.setTextFilterEnabled(真);
发送=(按钮)findViewById(R.id.button1);
send.setOnClickListener(新OnClickListener()
{ @覆盖
公共无效的onClick(视图v){
StringBuilder的checkedcontacts =新的StringBuilder();
的System.out.println(..............+ ma.mCheckStates.size());
的for(int i = 0; I< name1.size();我++) {
如果(ma.mCheckStates.get(我)==真)
{
phno0.add(phno1.get(ⅰ)的ToString());
checkedcontacts.append(name1.get(ⅰ)的ToString());
checkedcontacts.append(\\ n); }
其他
{
的System.out.println(..未签......+ name1.get(I)的ToString());
}
}
Toast.makeText(MainActivity.this,checkedcontacts,1000).show();
意图returnIntent =新的Intent();
returnIntent.putStringArrayListExtra(名,phno0);
的setResult(RESULT_OK,returnIntent);
完(); }
});
}@覆盖
公共无效onItemClick(适配器视图<>为arg0,ARG1观,诠释ARG2,长ARG3){
// TODO自动生成方法存根
ma.toggle(ARG2);
}公共无效getAllCallLogs(ContentResolver的CR){ 光标手机= cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,NULL,NULL,NULL,NULL);
而(phones.moveToNext())
{
字符串名称= phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
串phoneNumber的= phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
的System.out.println(..................+ phoneNumber的);
name1.add(名);
phno1.add(phoneNumber的);
} phones.close();
}
类MyAdapter扩展了BaseAdapter实现CompoundButton.OnCheckedChangeListener
{私人SparseBooleanArray mCheckStates;
LayoutInflater mInflater;
TextView的TV1,电视;
复选框CB;
MyAdapter()
{
mCheckStates =新SparseBooleanArray(name1.size());
mInflater =(LayoutInflater)MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@覆盖
公众诠释的getCount(){
// TODO自动生成方法存根
返回name1.size();
} @覆盖
公共对象的getItem(INT位置){
// TODO自动生成方法存根
返回的位置;
} @覆盖
众长getItemId(INT位置){
// TODO自动生成方法存根 返回0;
} @覆盖
公共查看getView(最终诠释的立场,观点convertView,父母的ViewGroup){
// TODO自动生成方法存根
查看VI = convertView;
如果(convertView == NULL)
VI = mInflater.inflate(R.layout.row,NULL);
电视=(TextView中)vi.findViewById(R.id.textView1);
TV1 =(TextView中)vi.findViewById(R.id.textView2);
CB =(复选框)vi.findViewById(R.id.checkBox1);
tv.setText(姓名:+ name1.get(位置));
tv1.setText(电话号码:+ phno1.get(位置));
cb.setTag(位置);
cb.setChecked(mCheckStates.get(位置,FALSE));
cb.setOnCheckedChangeListener(本); 返回VI;
}
公共布尔器isChecked(INT位置){
返回mCheckStates.get(位置,FALSE);
} 公共无效setChecked(INT位置,布尔器isChecked){
mCheckStates.put(位置,器isChecked);
} 公共无效切换(INT位置){
setChecked(位置,器isChecked(位置)!);
}
@覆盖
公共无效onCheckedChanged(CompoundButton buttonView,
布尔器isChecked){
// TODO自动生成方法存根 mCheckStates.put((整数)buttonView.getTag(),器isChecked);
}
}
}
row.xml
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent><的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_alignParentTop =真
机器人:layout_marginLeft =15dp
机器人:layout_marginTop =34dp
机器人:文字=TextView的/><的TextView
机器人:ID =@ + ID / textView2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignBottom =@ + ID / checkBox1
机器人:layout_alignLeft =@ + ID / textView1
机器人:文字=TextView的/><复选框
机器人:ID =@ + ID / checkBox1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:layout_below =@ + ID / textView1
机器人:layout_marginRight =22dp
机器人:layout_marginTop =23dp/>
< / RelativeLayout的
清单文件
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.example.sendsmstoall
安卓版code =1
机器人:=的versionName1.0><用途-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =17/>
<使用许可权的android:NAME =android.permission.READ_CONTACTS/>
<使用许可权的android:NAME =android.permission.SEND_SMS/><应用
机器人:allowBackup =真
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名字=com.example.sendsmstoall.SendMessage
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/> <类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
<活动
机器人:名字=。MainActivity
机器人:标签=@字符串/ APP_NAME> < /活性GT;
< /用途>< /清单>
Right now i am able to select only one contact from my contacts in my phone,i want to send sms more person in my contact list ,how can i send.
Right now i cant add more contacts in the phone no edit text even in manually also and getting from contact list also.
I want to send more contact number in my contact list to send an sms.what can i do
public class SendSMSActivity extends Activity {
Button buttonSend,get;
private static final int CONTACT_PICKER_RESULT = 1001;
EditText phoneNo;
EditText textSMS;
int columnIndex_number;
static String stringNumber;
String sms;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.about);
phoneNo = (EditText)findViewById(R.id.editText1);
textSMS = (EditText) findViewById(R.id.editText2);
get = (Button) findViewById(R.id.button1);
get.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,
Contacts.CONTENT_URI);
startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
}
});
Intent intent1= getIntent(); // gets the previously created intent
final String firstKeyName = intent1.getStringExtra("firstKeyName");
textSMS.setText(firstKeyName);
buttonSend = (Button) findViewById(R.id.button2);
buttonSend.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v){
try {
String sms = textSMS.getText().toString().trim();
Toast.makeText(getApplicationContext(), phoneNo.getText().toString()+firstKeyName,
Toast.LENGTH_LONG).show();
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(phoneNo.getText().toString(), null, firstKeyName, null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
finish();
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
switch (requestCode) {
case CONTACT_PICKER_RESULT:
Cursor cursor = null;
String phoneNumber = "";
List<String> allNumbers = new ArrayList<String>();
int phoneIdx = 0;
try {
Uri result = data.getData();
String id = result.getLastPathSegment();
cursor = getContentResolver().query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + "=?", new String[] { id }, null);
phoneIdx = cursor.getColumnIndex(Phone.DATA);
if (cursor.moveToFirst()) {
while (cursor.isAfterLast() == false) {
phoneNumber = cursor.getString(phoneIdx);
allNumbers.add(phoneNumber);
phoneNo.setText(cursor.getString(phoneIdx));
cursor.moveToNext();
}
} else {
//no results actions
}
} catch (Exception e) {
//error actions
} finally {
if (cursor != null) {
cursor.close();
}
}
break;
}
} else {
//activity result error actions
}
}
}
Logcaterror its showing:
06-07 14:06:05.546: E/AndroidRuntime(780): FATAL EXCEPTION: main
06-07 14:06:05.546: E/AndroidRuntime(780): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.jsonandroid/com.example.jsonandroid.ContactActivity}; have you declared this activity in your AndroidManifest.xml?
06-07 14:06:05.546: E/AndroidRuntime(780): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.app.Activity.startActivityForResult(Activity.java:3370)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.app.Activity.startActivityForResult(Activity.java:3331)
06-07 14:06:05.546: E/AndroidRuntime(780): at com.example.jsonandroid.SendSMSActivity$1.onClick(SendSMSActivity.java:42)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.view.View.performClick(View.java:4202)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.view.View$PerformClick.run(View.java:17340)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.os.Handler.handleCallback(Handler.java:725)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.os.Handler.dispatchMessage(Handler.java:92)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.os.Looper.loop(Looper.java:137)
06-07 14:06:05.546: E/AndroidRuntime(780): at android.app.ActivityThread.main(ActivityThread.java:5039)
06-07 14:06:05.546: E/AndroidRuntime(780): at java.lang.reflect.Method.invokeNative(Native Method)
06-07 14:06:05.546: E/AndroidRuntime(780): at java.lang.reflect.Method.invoke(Method.java:511)
06-07 14:06:05.546: E/AndroidRuntime(780): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-07 14:06:05.546: E/AndroidRuntime(780): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-07 14:06:05.546: E/AndroidRuntime(780): at dalvik.system.NativeStart.main(Native Method)
You can get all contacts from the contact list and display it in a list. You can select the contacts using check box and click the button. Navigate to SendMessage activity and type the sms content and send message
I think there is a better way of dealing with checkboxes. For check box get selected item i followed the below link.
https://groups.google.com/forum/?fromgroups#!topic/android-developers/No0LrgJ6q2M
Also you can fetch columns that you only need. Below fetches all columns which is not good.
Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null);
get.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/button1"
android:id="@+id/lv"/>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginLeft="44dp"
android:text="Send" />
</RelativeLayout>
MainActivity.java
public class MainActivity extends Activity implements OnItemClickListener{
ArrayList<String> name1 = new ArrayList<String>();
ArrayList<String> phno1 = new ArrayList<String>();
ArrayList<String> phno0 = new ArrayList<String>();
MyAdapter ma ;
Button show,add;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get);
getAllCallLogs(this.getContentResolver());
ListView lv= (ListView) findViewById(R.id.lv);
ma = new MyAdapter();
lv.setAdapter(ma);
lv.setOnItemClickListener(this);
lv.setItemsCanFocus(false);
lv.setTextFilterEnabled(true);
// adding
add = (Button) findViewById(R.id.button1);
add.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
StringBuilder checkedcontacts= new StringBuilder();
System.out.println(".............."+ma.mCheckStates.size());
for(int i = 0; i < name1.size(); i++)
{
if(ma.mCheckStates.get(i)==true)
{
phno0.add(phno1.get(i).toString()) ;
checkedcontacts.append(name1.get(i).toString());
checkedcontacts.append("\n");
}
else
{
System.out.println("..Not Checked......"+name1.get(i).toString());
}
}
Toast.makeText(MainActivity.this, checkedcontacts,1000).show();
Intent intent = new Intent(new Intent(MainActivity.this,SendMessage.class));
intent.putStringArrayListExtra("name",phno0);
startActivity(intent);
}
});
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
ma.toggle(arg2);
}
public void getAllCallLogs(ContentResolver cr) {
Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null);
while (phones.moveToNext())
{
String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
System.out.println(".................."+phoneNumber);
name1.add(name);
phno1.add(phoneNumber);
}
phones.close();
}
class MyAdapter extends BaseAdapter implements CompoundButton.OnCheckedChangeListener
{ private SparseBooleanArray mCheckStates;
LayoutInflater mInflater;
TextView tv1,tv;
CheckBox cb;
MyAdapter()
{
mCheckStates = new SparseBooleanArray(name1.size());
mInflater = (LayoutInflater)MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return name1.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi=convertView;
if(convertView==null)
vi = mInflater.inflate(R.layout.row, null);
TextView tv= (TextView) vi.findViewById(R.id.textView1);
tv1= (TextView) vi.findViewById(R.id.textView2);
cb = (CheckBox) vi.findViewById(R.id.checkBox1);
tv.setText("Name :"+ name1.get(position));
tv1.setText("Phone No :"+ phno1.get(position));
cb.setTag(position);
cb.setChecked(mCheckStates.get(position, false));
cb.setOnCheckedChangeListener(this);
return vi;
}
public boolean isChecked(int position) {
return mCheckStates.get(position, false);
}
public void setChecked(int position, boolean isChecked) {
mCheckStates.put(position, isChecked);
}
public void toggle(int position) {
setChecked(position, !isChecked(position));
}
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
mCheckStates.put((Integer) buttonView.getTag(), isChecked);
}
}
}
SendMessage.java
public class SendMessage extends Activity {
EditText ed1,ed2;
ArrayList<String> sendlist = new ArrayList<String>();
Button b1;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sendmessage);
ed1= (EditText)findViewById(R.id.editText1);
ed2= (EditText)findViewById(R.id.editText2);
Bundle extras = getIntent().getExtras();
if(extras!=null)
{
sendlist = extras.getStringArrayList("name");
if(sendlist!=null)
{
for(int i=0;i<sendlist.size();i++)
{
ed1.append(sendlist.get(i).toString());
ed1.append(";");
}
}
}
else
{
Toast.makeText(getApplicationContext(), "null",
Toast.LENGTH_LONG).show();
}
b1 = (Button) findViewById(R.id.button1);
b1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
for(int i=0;i<sendlist.size();i++)
{
if(ed2.getText().length()>0)
{
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(sendlist.get(i).toString(), null, ed2.getText().toString(), null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}
}
});
}
}
sendmessage.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="18dp"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/editText1"
android:layout_marginTop="62dp"
android:ems="10" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/editText1"
android:layout_centerHorizontal="true"
android:text="Phone Numbers" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_centerHorizontal="true"
android:layout_marginTop="37dp"
android:text="Message" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_alignParentBottom="true"
android:text="Send" />
</RelativeLayout>
You need to add these two permissions
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.SEND_SMS" />
Edit:
Open SendMessage Activity first. Click the get button next to editext1. Navigate to MainActivity which displays all contacts and select using check boxes. Click send will finish the actiivty and retunn sms activity. You can see the selected contacts in editext 1. The rest is the same.
I have used startActivity for result. This more than i can do to help you. pls modify the same accordingly.
public class SendMessage extends Activity {
EditText ed1,ed2;
static int ResultCode= 12;
ArrayList<String> sendlist = new ArrayList<String>();
Button b1,b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.sendmessage);
b2 = (Button) findViewById(R.id.button2);
ed1= (EditText)findViewById(R.id.editText1);
ed2= (EditText)findViewById(R.id.editText2);
b1 = (Button) findViewById(R.id.button1);
b2.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(SendMessage.this, MainActivity.class);
startActivityForResult(i, ResultCode);
}
});
b1.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
for(int i=0;i<sendlist.size();i++)
{
if(ed2.getText().length()>0)
{
try {
SmsManager smsManager = SmsManager.getDefault();
smsManager.sendTextMessage(sendlist.get(i).toString(), null, ed2.getText().toString(), null, null);
Toast.makeText(getApplicationContext(), "SMS Sent!",
Toast.LENGTH_LONG).show();
} catch (Exception e) {
Toast.makeText(getApplicationContext(),
"SMS faild, please try again later!",
Toast.LENGTH_LONG).show();
e.printStackTrace();
}
}
}
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == ResultCode) {
if(resultCode == RESULT_OK){
sendlist =data.getStringArrayListExtra("name");
if(sendlist!=null)
{
for(int i=0;i<sendlist.size();i++)
{
ed1.append(sendlist.get(i).toString());
ed1.append(";");
}
}
if (resultCode == RESULT_CANCELED) {
}
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="18dp"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/editText1"
android:layout_marginTop="62dp"
android:ems="10" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/editText1"
android:layout_centerHorizontal="true"
android:text="Phone Numbers" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText1"
android:layout_centerHorizontal="true"
android:layout_marginTop="37dp"
android:text="Message" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_alignParentBottom="true"
android:text="Send" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_alignParentRight="true"
android:text="Get" />
</RelativeLayout>
MainActivity
public class MainActivity extends Activity implements OnItemClickListener{
ArrayList<String> name1 = new ArrayList<String>();
ArrayList<String> phno1 = new ArrayList<String>();
ArrayList<String> phno0 = new ArrayList<String>();
MyAdapter ma ;
Button send;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.get);
getAllCallLogs(this.getContentResolver());
ListView lv= (ListView) findViewById(R.id.lv);
ma = new MyAdapter();
lv.setAdapter(ma);
lv.setOnItemClickListener(this);
lv.setItemsCanFocus(false);
lv.setTextFilterEnabled(true);
send = (Button) findViewById(R.id.button1);
send.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v) {
StringBuilder checkedcontacts= new StringBuilder();
System.out.println(".............."+ma.mCheckStates.size());
for(int i = 0; i < name1.size(); i++)
{
if(ma.mCheckStates.get(i)==true)
{
phno0.add(phno1.get(i).toString()) ;
checkedcontacts.append(name1.get(i).toString());
checkedcontacts.append("\n");
}
else
{
System.out.println("..Not Checked......"+name1.get(i).toString());
}
}
Toast.makeText(MainActivity.this, checkedcontacts,1000).show();
Intent returnIntent = new Intent();
returnIntent.putStringArrayListExtra("name",phno0);
setResult(RESULT_OK,returnIntent);
finish();
}
});
}
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// TODO Auto-generated method stub
ma.toggle(arg2);
}
public void getAllCallLogs(ContentResolver cr) {
Cursor phones = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,null,null, null);
while (phones.moveToNext())
{
String name=phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
System.out.println(".................."+phoneNumber);
name1.add(name);
phno1.add(phoneNumber);
}
phones.close();
}
class MyAdapter extends BaseAdapter implements CompoundButton.OnCheckedChangeListener
{ private SparseBooleanArray mCheckStates;
LayoutInflater mInflater;
TextView tv1,tv;
CheckBox cb;
MyAdapter()
{
mCheckStates = new SparseBooleanArray(name1.size());
mInflater = (LayoutInflater)MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return name1.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View vi=convertView;
if(convertView==null)
vi = mInflater.inflate(R.layout.row, null);
tv= (TextView) vi.findViewById(R.id.textView1);
tv1= (TextView) vi.findViewById(R.id.textView2);
cb = (CheckBox) vi.findViewById(R.id.checkBox1);
tv.setText("Name :"+ name1.get(position));
tv1.setText("Phone No :"+ phno1.get(position));
cb.setTag(position);
cb.setChecked(mCheckStates.get(position, false));
cb.setOnCheckedChangeListener(this);
return vi;
}
public boolean isChecked(int position) {
return mCheckStates.get(position, false);
}
public void setChecked(int position, boolean isChecked) {
mCheckStates.put(position, isChecked);
}
public void toggle(int position) {
setChecked(position, !isChecked(position));
}
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
// TODO Auto-generated method stub
mCheckStates.put((Integer) buttonView.getTag(), isChecked);
}
}
}
row.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="15dp"
android:layout_marginTop="34dp"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/checkBox1"
android:layout_alignLeft="@+id/textView1"
android:text="TextView" />
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="@+id/textView1"
android:layout_marginRight="22dp"
android:layout_marginTop="23dp" />
</RelativeLayout
Manifest file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.sendsmstoall"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.SEND_SMS" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.sendsmstoall.SendMessage"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
这篇关于如何从我的联系人列表中选择多个联系人发送SMS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!