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);
精彩评论