Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/178.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
操作\u发送android.content.Intent.EXTRA\u电子邮件android.content.Intent.EXTRA\u主题android.content.Intent.EXTRA\u文本您可以这样做尝试…:)有什么问题?应用程序崩溃了_Android_Email - Fatal编程技术网

操作\u发送android.content.Intent.EXTRA\u电子邮件android.content.Intent.EXTRA\u主题android.content.Intent.EXTRA\u文本您可以这样做尝试…:)有什么问题?应用程序崩溃了

操作\u发送android.content.Intent.EXTRA\u电子邮件android.content.Intent.EXTRA\u主题android.content.Intent.EXTRA\u文本您可以这样做尝试…:)有什么问题?应用程序崩溃了,android,email,Android,Email,操作\u发送android.content.Intent.EXTRA\u电子邮件android.content.Intent.EXTRA\u主题android.content.Intent.EXTRA\u文本您可以这样做尝试…:)有什么问题?应用程序崩溃了吗?有错误吗?检查堆栈溢出的这个链接可能会有帮助@Shreya S:No errors。。它根本不发送电子邮件。。把邮件拿出来。但我根本无法发送电子邮件,从列表到字符串[]的转换错误,即List List=new ArrayList();Str



操作\u发送android.content.Intent.EXTRA\u电子邮件android.content.Intent.EXTRA\u主题android.content.Intent.EXTRA\u文本您可以这样做尝试…:)有什么问题?应用程序崩溃了吗?有错误吗?检查堆栈溢出的这个链接可能会有帮助@Shreya S:No errors。。它根本不发送电子邮件。。把邮件拿出来。但我根本无法发送电子邮件,从列表到字符串[]的转换错误,即List List=new ArrayList();String[]ArrayOfString=list.toArray(新字符串[list.size()]);实际上,您需要这样做。在Intent之前,您可以添加android.content.Intent.ACTION\u发送android.content.Intent.EXTRA\u电子邮件android.content.Intent.EXTRA\u主题android.content.Intent.EXTRA\u您可以这样做尝试…:)尝试使用
public Intent putStringArrayListExtra(字符串名称,ArrayList值)
并将emailList作为值传递-我刚刚注意到,由于toArray方法的返回值可能会导致问题,to被声明为Object[]而不是String[],我的一半问题现在已经解决了。请按照Harish的建议执行。地址出现在电子邮件客户端的“收件人”字段中,但电子邮件不会发送,即使它显示发送消息,这将是我的下一个建议,我认为字符串数组列表额外方法将只是一个方便的方法,很高兴听到您将其排序:)尝试使用
public Intent putStringArrayListExtra(字符串名称,ArrayList值)
并将emailList作为值传递-我刚刚注意到to被声明为Object[]而不是String[]由于toArray方法的返回值可能会导致问题,我的一半问题现在已解决。请按照Harish的建议进行操作。地址出现在电子邮件客户端的“收件人”字段中,但电子邮件不会发送,即使它显示发送消息,这将是我的下一个建议,我认为字符串数组列表额外方法将只是一个方便的方法,很高兴听到你把它整理好:)非常感谢你的帮助:)非常感谢你的帮助:)
public class SendEmailActivity extends Activity{

EditText subject_ed,message_ed;
TextView subject_tv,message_tv;
Button send_btn;

 ArrayList<String> emailList;
 ArrayList<Integer> idList;
 int eventId;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.contacts_email_sms_layout);
    setupViews();
    Intent intent = getIntent();
    Bundle b = intent.getExtras();
    eventId =  b.getInt("EventId");//event id
    idList = b.getIntegerArrayList("IdList");//list of Ids
    emailList = b.getStringArrayList("EmailList");//list of email ids
    buttonListeners();
}

public void setupViews()
{
    subject_ed = (EditText)findViewById(R.id.ed_subject_email);
    message_ed = (EditText)findViewById(R.id.ed_msg_body);
    subject_tv = (TextView)findViewById(R.id.tv_subject_email);
    message_tv = (TextView)findViewById(R.id.tv_msg_body);
    send_btn = (Button)findViewById(R.id.btn_send_sms_email);
}               

public void buttonListeners()
{
    send_btn.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "Email sent",Toast.LENGTH_LONG).show();
            // String to = textTo.getText().toString();
              String subject = subject_ed.getText().toString();
              String message = message_ed.getText().toString();
            Object[] to =  emailList.toArray();
//            for(int i = 0; i<=emailList.size(); i++)
////                  {
////                      
//                  String  to=   emailList.get(0);
////                     
////                  }



              Intent email = new Intent(Intent.ACTION_SEND);
              for(int i = 0; i < to.length; i++)
                {
                    Log.i("String is", (String)to[i]);
                    //String[] str = (String[])to[i];
                     email.putExtra(Intent.EXTRA_EMAIL,",'" +(String)to[i] + "'");
                }

              email.putExtra(Intent.EXTRA_SUBJECT, subject);
              email.putExtra(Intent.EXTRA_TEXT, message);

              //need this to prompts email client only
              email.setType("message/rfc822");

              startActivity(Intent.createChooser(email, "Choose an Email client :"));
             // finish();
        }
    });
}

}
public Intent putExtra (String name, String value)
public Intent putExtra (String name, String[] value)
for(int i = 0; i < to.length; i++)
{
    Log.i("String is", (String)to[i]);
    //String[] str = (String[])to[i];
    email.putExtra(Intent.EXTRA_EMAIL,",'" +(String)to[i] + "'");
}
email.putExtra(Intent.EXTRA_EMAIL, to);
button.Onclick(){
  // get all the messages information
  // the button to send the emails has been collected
  new SendEmailTask().execute(messages)
}
SendEmailTask extends AsyncTask<Message,Void,Void>(){

  function doInBackground(Message... msgs){
    for(Message m : msgs){
     // process each of your messages
     // send the messages out
    }
  }
  function onPostExecute(){
    // tell the UI thread that you are finished
  }

}
List<String> list = new ArrayList<String>();
String[] arrayOfStrings = list.toArray(new String[list.size()]);
ArrayList<String> emailList;
emailList = b.getStringArrayList("EmailList");
String[] emailArray;

Intent email = new Intent(android.content.Intent.ACTION_SEND);

for(int i = 0; i < to.length; i++){
    Log.i("String is", (String)to[i]);
    email.putExtra(android.content.Intent.EXTRA_EMAIL, 
                   emailList.toArray(new String[emailList.size()]));
}
email.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
email.putExtra(android.content.Intent.EXTRA_TEXT, message);    
email.setType("message/rfc822"); //or email.setType("text/plain");

startActivity(Intent.createChooser(email, "Choose an Email client :"));