Android多个联系人信息发送

时间:2015-09-28 04:56:10

标签: android listview contacts

在我的Android应用程序中,我从所选联系人中选择了多个联系人,我正在向特定号码发送消息,并且此应用程序在模拟器中正常工作。但是当我用手机检查时,它无法正常工作。到选定的联系人消息,但该应用程序崩溃后。如果有人可以提供帮助,我会给出以下代码。

SmsManager smsManager = SmsManager.getDefault();
                        // Find out which contacts are selected
                        for (int i = 0; i < listView.getCount(); i++) {
                            View item = (View) listView.getChildAt(i);
                            boolean selected = ((CheckBox) item.findViewById(R.id.selected)).isChecked();
                            if (selected) {
                                String mobile = ((TextView) item.findViewById(R.id.mobile)).getText().toString();

                                try {
                                    smsManager.sendTextMessage(mobile, null, editMessage.getText().toString(), null, null);


                                } catch (Exception ex) {
                                    Log.d("Mobile", "Could not send message to " + mobile);

                                }
                            }


                        }

                        Intent suc = new Intent(SendMessagesActivity.this, Login_Activity.class);
                        startActivity(suc);




<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
    <uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
    <uses-permission android:name="android.permission.SEND_SMS" />
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.RECEIVE_SMS"/>

0 个答案:

没有答案