Android send SMS to multiple contacts using ArrayList

后端 未结 1 1813
北恋
北恋 2021-01-07 02:36

Im writing an app that sends an SMS to several contacts. The contacts numbers are stored in an ArrayList (was received from another activity). I am not able to

相关标签:
1条回答
  • 2021-01-07 03:21

    Use this code..

    String toNumbers = "";
    for ( String s : numbersArrayList)  
    {  
        toNumbers = toNumbers + s + ";"
    }  
    toNumbers = toNumbers.subString(0, toNumbers.length - 1);
    String message= "this is a custom message";
    
    Uri sendSmsTo = Uri.parse("smsto:" + toNumbers);
                    Intent intent = new Intent(
                            android.content.Intent.ACTION_SENDTO, sendSmsTo);
                    intent.putExtra("sms_body", message);
                    startActivity(intent); 
    
    0 讨论(0)
提交回复
热议问题