Question

I am sending email using the following code below.

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/html");
i.putExtra(Intent.EXTRA_SUBJECT, this.news.getNewsTitle());
i.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(this.htmlContentDetails));

try {
         startActivity(Intent.createChooser(i, "Sending mail..."));
} catch (android.content.ActivityNotFoundException e) {
         Toast.makeText(this, "There are no email clients installed.",
         Toast.LENGTH_SHORT).show();
}

But when the view comes to focus again, its only displaying the place holder title and details text. But this does not happens every time. And it never happens if cancel/back button is pressed after selecting the email client.

Only happens randomly after sending the email.

Was it helpful?

Solution

could you review your methods onStop, onStart onResume onPause and so on, seems that you have configuration variables that holds the state or information that in a certain circunstance are not working as espected. this doesn't have anything to do with the intent it self.

OTHER TIPS

You show call it as startActivityForResult and upon successful completion of sending email, in your onActivityResult method, set the Title and Details text by preserving it before starting the email intent.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top