<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>A Dash of Web and Mobile Development &#187; html</title>
	<atom:link href="http://blog.iangclifton.com/tag/html/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.iangclifton.com</link>
	<description>Discussing trends and technologies in web and mobile development</description>
	<lastBuildDate>Fri, 03 Feb 2012 05:15:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Android TextView And HTML Links</title>
		<link>http://blog.iangclifton.com/2010/12/30/android-textview-and-html-links/</link>
		<comments>http://blog.iangclifton.com/2010/12/30/android-textview-and-html-links/#comments</comments>
		<pubDate>Thu, 30 Dec 2010 22:28:36 +0000</pubDate>
		<dc:creator>Ian G. Clifton</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[textview]]></category>

		<guid isPermaLink="false">http://blog.iangclifton.com/?p=354</guid>
		<description><![CDATA[Android&#8217;s TextView widget is actually quite robust. It supports various fonts, styles, colors, etc., allowing you to have newlines, bold sections, and more (even defined from XML); however, sometimes the text you are dumping into a TextView is HTML. Fortunately, &#8230; <a href="http://blog.iangclifton.com/2010/12/30/android-textview-and-html-links/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Android&#8217;s <a href="http://developer.android.com/reference/android/widget/TextView.html">TextView</a> widget is actually quite robust.  It supports various fonts, styles, colors, etc., allowing you to have newlines, bold sections, and more (even <a href="http://developer.android.com/guide/appendix/faq/commontasks.html#selectingtext">defined from XML</a>); however, sometimes the text you are dumping into a TextView is HTML.  Fortunately, it&#8217;s easy to add HTML to a TextView:</p>
<pre class="brush: java; title: ; notranslate">
textView.setText(Html.fromHtml(htmlString));
</pre>
<p><a href="http://developer.android.com/reference/android/text/Html.html#fromHtml(java.lang.String)">Html.fromHtml()</a> returns a <a href="http://developer.android.com/reference/android/text/Spanned.html">Spanned</a> and the TextView does the rest for you.<span id="more-354"></span>  You don&#8217;t have to worry about parsing any HTML; it is handled by <a href="http://developer.android.com/reference/org/xml/sax/XMLReader.html">XMLReader</a> for you, which is extremely fast.  Your TextView will show bold text, italicized text, links, and&#8230; wait, the links are blue and underlined but not usable?  Fortunately, all you have to do is set the TextView to use the <a href="http://developer.android.com/reference/android/text/method/LinkMovementMethod.html">LinkMovementMethod</a> like this:</p>
<pre class="brush: java; title: ; notranslate">
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setLinksClickable(true);
</pre>
<p>The setMovementMethod call will allow the arrow keys, trackball, touch screen, etc. to interact with the anchor tags in your HTML.  I found that the call to setLinksClickable was necessary on Android 1.5 but not 2.2.1.  It&#8217;s worth noting that the setMovementMethod call (when not passed null) will actually also call these methods on your TextView:</p>
<pre class="brush: java; title: ; notranslate">
setFocusable(true);
setClickable(true);
setLongClickable(true);
</pre>
<p>If you want any of those values to be false, you&#8217;ll have to call the applicable method after the setMovementMethod call.</p>
<p>So, what tags are supported?  There isn&#8217;t an official list in the documentation, so I recommend sticking to the most common tags (br, b, i, etc.); however, the following tags have at least some handling done in the Html class:</p>
<ul>
<li>a</li>
<li>b</li>
<li>big</li>
<li>blockquote</li>
<li>br</li>
<li>cite</li>
<li>dfn</li>
<li>div</li>
<li>em</li>
<li>font</li>
<li>h1-h6</li>
<li>i</li>
<li>img</li>
<li>p</li>
<li>small</li>
<li>strong</li>
<li>sup</li>
<li>sup</li>
<li>tt</li>
<li>u</li>
</ul>
<p>Really though, if your HTML is complex enough to contain images, inline CSS, etc., you should be using a WebView.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iangclifton.com/2010/12/30/android-textview-and-html-links/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sending HTML Email With Android Intent</title>
		<link>http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/</link>
		<comments>http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/#comments</comments>
		<pubDate>Tue, 18 May 2010 02:55:15 +0000</pubDate>
		<dc:creator>Ian G. Clifton</dc:creator>
				<category><![CDATA[Code Samples]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://blog.iangclifton.com/?p=216</guid>
		<description><![CDATA[It&#8217;s very easy to send email via an Android intent. Here&#8217;s an example where we already have the subject and body prepared but want to let the user decide on the recipient: (It&#8217;s important to note that this should be &#8230; <a href="http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s very easy to send email via an Android intent.  Here&#8217;s an example where we already have the subject and body prepared but want to let the user decide on the recipient:</p>
<pre class="brush: java; title: ; notranslate">
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType(&quot;text/plain&quot;);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
startActivity(Intent.createChooser(emailIntent, &quot;Email:&quot;));
</pre>
<p>(It&#8217;s important to note that this should be attempted on a real device.)<span id="more-216"></span></p>
<p>I ran into some trouble with sending HTML in an email because it was being interpreted as plain text both in the user&#8217;s email client and in the recipient&#8217;s.  Simply changing the MIME type didn&#8217;t help, but I eventually came across the solution:</p>
<pre class="brush: java; title: ; notranslate">
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType(&quot;text/html&quot;);
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));
startActivity(Intent.createChooser(emailIntent, &quot;Email:&quot;));
</pre>
<p>Note that both the MIME type is changed and the EXTRA_TEXT is now set as <code>Html.fromHtml(body)</code> instead of just being passed a string with HTML in it.  As long as the mail app that is selected is able to properly handle the Intent (e.g., the Gmail app can, the default mail app cannot), then HTML email can be sent.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/feed/</wfw:commentRss>
		<slash:comments>51</slash:comments>
		</item>
		<item>
		<title>Setting An Image For Facebook Link Sharing</title>
		<link>http://blog.iangclifton.com/2009/12/31/setting-an-image-for-facebook-link-sharing/</link>
		<comments>http://blog.iangclifton.com/2009/12/31/setting-an-image-for-facebook-link-sharing/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 10:02:03 +0000</pubDate>
		<dc:creator>Ian G. Clifton</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://blog.iangclifton.com/?p=82</guid>
		<description><![CDATA[When you attach a link to share on Facebook, you&#8217;re typically presented with up to nine thumbnails pulled from img tags on that site. In many cases, one of these thumbnails will work fine, but sometimes the images aren&#8217;t ideal &#8230; <a href="http://blog.iangclifton.com/2009/12/31/setting-an-image-for-facebook-link-sharing/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you attach a link to share on Facebook, you&#8217;re typically presented with up to nine thumbnails pulled from img tags on that site.  In many cases, one of these thumbnails will work fine, but sometimes the images aren&#8217;t ideal or the site owner wants a specific image to show up.  Fortunately, there&#8217;s a simple tag you can add to solve this problem.<span id="more-82"></span></p>
<p><code>&lt;link rel="image_src" href="http://example.com/logo.png" /&gt;</code></p>
<p>Just put that tag in the head portion of your HTML, and the image specified (in this case &#8220;logo.png&#8221;) will be the new default (and only) choice for Facebook sharing.  There are a few things that you should know though.  First, Facebook caches these images, so you may not see the immediate change.  I&#8217;m not sure exactly how long the cache is, but I saw changes in under 24 hours on a site I was working on.  The other really big thing to know about is that Facebook has specific rules for the image:</p>
<blockquote><p>The thumbnail&#8217;s width or height must be at least 50 pixels, and cannot exceed 130&#215;110 pixels. The ratio of both height divided by width and width divided by height (w / h, h / w) cannot exceed 3.0. For example, an image of 126&#215;39 pixels will not be displayed, as the ratio of width divided by height is greater than 3.0 (126 / 39 = 3.23). Images will be resized proportionally. </p></blockquote>
<p>That&#8217;s per the <a href="http://wiki.developers.facebook.com/index.php/Facebook_Share/Specifying_Meta_Tags">developer wiki</a>.  Although some other sites also make use of the tag and specified image, your image must meet these requirements for it to work with Facebook sharing.  If your image does not meet these requirements, it will not show up at all, and no other options will show up either.  People will not be able to select any thumbnail when sharing your site.</p>
<p>It&#8217;s also worth noting that Facebook makes use of the traditional meta tags (title and description), so you should be sure to include those on your pages.  I know many people have gotten out of the habit of adding them in because they were most commonly used with search indexing, but most search engines use context from your actual content instead of those tags.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.iangclifton.com/2009/12/31/setting-an-image-for-facebook-link-sharing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

