Html Display in Email Body Android - android

I want to display a table in email body. The code is as below.
stringBuilder.append("<html>" +
"<body>"+
"<table border=\"1\">"+
"<tr>"+
"<th>Name</th>"+
"<th>Telephone</th>"+
"<th>Telephone</th>"+
"</tr>"+
"<tr>"+
"<td>Bill Gates</td>"+
"<td>555 77 854</td>"+
"<td>555 77 855</td>"+
"</tr>"+
"</table>"+
"</body>"+
"</html>");
final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
intent.setType("text/html");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Checklist Information");
intent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(stringBuilder.toString()));
But the table is not showing, rather a simple text is showing in mail body.
Please help me out.

the table html tag is not supported by Html.fromHtml(). See here

Related

Customize URL for sharing intent

It's pretty clear to me how to share a link with the Android sharing Intent...
This is what I usually do:
final String extraText = "String 1";
final String searchUrl = "http://www.example.com?utm_source=SOURCE&utm_medium=social&utm_campaign=socialbuttons&utm_content=app_android";
final Intent intent = new Intent(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_SUBJECT, "TITLE").putExtra(Intent.EXTRA_TEXT, extraText + "\n" + searchUrl);
BUT
I would like to customize the tracking in the url for different kind of shares...
Twitter:
http://www.example.com?utm_source=TWITTER&utm_medium=social&utm_campaign=socialbuttons&utm_content=app_android
Facebook:
http://www.example.com?utm_source=FACEBOOK&utm_medium=social&utm_campaign=socialbuttons&utm_content=app_android
Etc...
Is it possible? How can I do it?

How to attach 3 fields in email body in an android email application

Normally email apps only have an EditText where the app copies what the user writes and pastes it into the email client's body.
I have 2 more fields, specifically 2 TextViews that contain Longitude and Latitude coordinations and I also want those to appear inside the email body.
I'm using this code, but only the latest String appears in the mail (lat)
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"email#email.com"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, message);
emailIntent.putExtra(Intent.EXTRA_TEXT, longi);
emailIntent.putExtra(Intent.EXTRA_TEXT, lat);
emailIntent.setType("message/rfc822");
emailIntent.putExtra(Intent.EXTRA_STREAM, imageUri);
startActivity(Intent.createChooser(emailIntent, "Choose an Email client"));
The second and third times that you call putExtra() for Intent.EXTRA_TEXT, you are replacing the previous value.
Instead, create one string that contains the entire message, including the longi and lat values, and use putExtra() for Intent.EXTRA_TEXT on that one string.
Construct a string with all three fields.
String text = "";
text += message + "\n" + longi + "\n" + lat;
emailIntent.putExtra(Intent.EXTRA_TEXT, text);
Of course use text and formatting as you like.

Android ACTION_SEND

i wanna make an action that the android app can send an email, and the email subject and body already fill with the edittext from the android app.
here's my code
Intent ii = new Intent(android.content.Intent.ACTION_SEND);
ii.setType("text/plain");
EditText txtName = (EditText)findViewById(R.id.txtName);
EditText txtAddress = (EditText)findViewById(R.id.txtAddress);
EditText txtLatitude = (EditText)findViewById(R.id.txtLatitude);
EditText txtLongitude = (EditText)findViewById(R.id.txtLongitude);
ii.putExtra(android.content.Intent.EXTRA_SUBJECT, txtName.getText().toString());
ii.putExtra(android.content.Intent.EXTRA_TEXT, txtAddress.getText().toString());
ii.putExtra(android.content.Intent.EXTRA_TEXT, txtLatitude.getText().toString());
ii.putExtra(android.content.Intent.EXTRA_TEXT, txtLongitude.getText().toString());
startActivity(Intent.createChooser(ii, "Share via"));
The subject is fine, but the body email is only fill with the last content(txtLongitude).
please tell me what to do.
Gratz.
You need to first make one string from the 3 EditTexts, then set it as an extra. For Example:
String body = txtName.getText().toString() + txtLatitude.getText().toString() + txtLongitude.getText().toString()
ii.putExtra(android.content.Intent.EXTRA_TEXT, body);
You'll probably also want to add some things like new line characters to format the text.
The subject is fine, but the body email is only fill with the last content(txtLongitude).
That is because you keep overriding the same EXTRA_TEXT extra. Call putExtra() for EXTRA_TEXT once, with the complete body of the email you want to send.

Using HTML in a String

In my application I have to use a some HTML stuff in a string. But HTML is not working as intended. I have to use that string (Text) to send as an email. The sequence I required of HTML is:
Title (in the center)
Image (in the center)
Description (left align)
and then this HTML string is passed to an email intent. But neither image is showing up in the email nor the title text is getting center align. This is how I am doing this all:
Intent it = new Intent(Intent.ACTION_SEND);
it.putExtra(Intent.EXTRA_EMAIL, "");
it.setType("text/html");
String title = title;
String emailText = emailText;
it.putExtra(Intent.EXTRA_SUBJECT, title);
it.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(emailText));
this.startActivity(it);
and this is how the emailText is being formed:
emailText = "<p style= 'color:#000000; font:Georgia; font-size:18pt; text-align:center' align = 'center'><b>" + title +" </b></p>"
+"<br/><br />"
+"<img style=\"border:3px solid #173E8C\" src=\'" +imageUrl+"\' width=\"120\" height=\"90\"align=\"center\"/>"
+"<br/><br/>"
+"<p>" + description;
But I am unable to get the required result that I have mentioned right at the top, Any help is appreciated related to the issue. Thanks in advance..:-)
You must specify the type of email through the function setType () :
it.setType("text/html"); // for HTML
it.setType("text/plain"); // for plain text
You can't send a image as email body in android through Intent.

pass text to facebook wall on a button click android

I have to publish some text and image from a button on the xml layout, onclick of the button it will call an activity to share but how to pass text and images to face book through android.
please help me with an example.
probably through the facebook-api
Check this Code for Adding Image and Title in Facebook Post Wall :
String link ="www.google.com";
String image_url="http://dev.campusflock.com/img/medium_big_thumb/Deal/15.d23a69cbfb987be82dbfa563258080b9.jpg";
parameters.putString("method", "stream.publish");
parameters.putString(
"attachment",
"{\"name\":\""
+ "companyName"
+ "\",\"href\":\""
+ link
+ "\",\"description\":\""
+ "Title"
+ "\",\"media\":[{\"type\":\"image\",\"src\":\""+image_url+"\",\"href\":\"" +link+"\"}]}");
authenticatedFacebook.dialog(Main.this, "stream.publish",parameters, new TestUiServerListener());

Categories

Resources