开发者

Activity within activity

I am trying to start an activity in my main activity. I am trying to send data via email. But when i run the code my program crash . here is my code of starting new activity

Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("plain/html");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"aaa@gmail.com","ssss@yahoo.com"});
    intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
    intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("my html text goes here"));
  开发者_开发问答  startActivity(intent);


Try using Intent.createChooser method to find an application that should send your mail, like this:

    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType(EMAIL_CONTENT_TYPE);

    emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"aaa@gmail.com","ssss@yahoo.com"});
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
    emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("my html text goes here"));

    Intent chooser = Intent.createChooser(emailIntent, "Choose the application to send the email");
    startActivity(chooser);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜