<?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>Josh Dale</title>
	<atom:link href="http://www.joshdale.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joshdale.net</link>
	<description>Android Developer at Bypass Lane, Homebrewer</description>
	<lastBuildDate>Sun, 29 Apr 2012 14:23:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Avoiding Off-flavors When Homebrewing, Part 2</title>
		<link>http://www.joshdale.net/2012/04/06/avoiding-off-flavors-when-homebrewing-part-2/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=avoiding-off-flavors-when-homebrewing-part-2</link>
		<comments>http://www.joshdale.net/2012/04/06/avoiding-off-flavors-when-homebrewing-part-2/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 13:45:39 +0000</pubDate>
		<dc:creator>Josh Dale</dc:creator>
				<category><![CDATA[Homebrew]]></category>
		<category><![CDATA[beer]]></category>
		<category><![CDATA[fermentation]]></category>
		<category><![CDATA[off-flavors]]></category>

		<guid isPermaLink="false">http://www.joshdale.net/?p=435</guid>
		<description><![CDATA[To continue off where I started, here&#8217;s a few more indicators that will determine what went wrong in your brewing process. I will discuss Husky or Grainy, Medicinal, Metallic, Moldy, Oxidation, Soapy, and Skunky. Husky or Grainy After tastes/flavors: like &#8230; <a href="http://www.joshdale.net/2012/04/06/avoiding-off-flavors-when-homebrewing-part-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>To continue off where I started, here&#8217;s a few more indicators that will determine what went wrong in your brewing process.  I will discuss Husky or Grainy, Medicinal, Metallic, Moldy, Oxidation, Soapy, and Skunky.</p>
<h2>Husky or Grainy</h2>
<p><strong>After tastes/flavors:</strong>  like cereal or raw grains.</p>
<p>A grainy taste indicates that you&#8217;ve over milled your grains.  This also may be because the grain is overly toasted.  You will find this off-flavor in &#8220;All-grain&#8221; batches.  To avoid, try to let your grain age for a week or two after milling.  This will allow for the harsh aromas and flavor to dissipate.</p>
<p><span id="more-435"></span></p>
<h2>Medicinal</h2>
<p><strong>After tastes/flavors:</strong>  cough syrup, Band-aids, smoky, clovers (spices).</p>
<p>Phenols are usually to blame for this off-taste.  These phenols react to chlorine-based sanitizers, so it&#8217;s best to boil your equipment with hot water, or use <a href="http://www.austinhomebrew.com/product_info.php?cPath=178_56_36&#038;products_id=11166&#038;osCsid=b1f895019ae1f1d0c7487346dcb74934">BrewVent Sanitizer</a> because it&#8217;s oxygen based not chlorine based, so there&#8217;s no need to rinse off.</p>
<h2>Metallic</h2>
<p><strong>After tastes/flavors:</strong>  metal, iron, sometimes described like pennies or blood.</p>
<p>If the wort is processed in unprocessed metals (cast iron, sometimes aluminum and steel) will cause this flavoring.  Kegs or bottle caps can also be a source for this flavor.  So, use stainless steel where you can for the majority of all your brewing equipment.</p>
<h2>Moldy</h2>
<p><strong>After tastes/flavors:</strong>  mold, mildew, musty.</p>
<p>Mold can definitely grow in beer, so make sure all your equipment is clean and sanitized.  If your fermenting in a damp, danky area rather than a cool dry area, mold can grow in your brew while in the fermenter.  Try to keep this area dry and cool.  If you see that you have moldy grain, discard it.</p>
<h2>Oxidation</h2>
<p><strong>After tastes/flavors:</strong> stale or old tasting, wet cardboard, increased bitterness.</p>
<p>Oxidation occurs when oxygen negatively affects your beer, i.e. too much oxygen in the concoction.  If you leave too much air in the bottle when bottling, this will sometimes lead to oxidation flavors.  You can prevent this from happening if you reduce your &#8220;splashing&#8221; from one container to another.  &#8220;Splashing&#8221; introduces more air to your brew, which isn&#8217;t good for a final product.</p>
<h2>Soapy</h2>
<p><strong>After tastes/flavors:</strong>  soap, bitter, slippery.</p>
<p>Soap residue not properly washed off equipment or partaking glasses.  Also, if you leave the beer in the fermenter for too long, then the fermentation process with break down fatty acids to create a soapy flavor in your beer.  Properly wash all equipment and boil them if needed.  Partaking glasses should be washed thoroughly with hot water.</p>
<h2>Skunky</h2>
<p><strong>After tastes/flavors:</strong> like a skunk, rubbery, cat musk.</p>
<p>When your hops are exposed to sun light or UV lights.  The acids in the hops will breakdown yielding hydrogen sulfide that reacts to the yeast.  The reaction is called Mercaptain and is the same chemical skunks produce when they spray their targets.  To void this flavor, ferment away from direct sunlight.  Bottle your beer in dark, brown bottles.  And, store your brew in a dark, cool area.</p>
<p>There are a few other flavors left on the list that I will cover shortly in the next post.  Stay tuned!</p>
<p>Also, check out these great sources: <a href="http://morebeer.com/content/homebrew-off-flavors" target="_blank">morebeer.com</a> and <a href="http://www.howtobrew.com/section4/chapter21-2.html" target="_blank">howtobrew.com</a>.  They both have great information if you&#8217;re starting to make your own damn beer.  Also, check out <a href="http://www.austinhomebrew.com" target="_blank">austinhomebrew.com</a> for beer kits, recipes, instruction, and anything homebrew.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshdale.net/2012/04/06/avoiding-off-flavors-when-homebrewing-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Avoid Off-flavors in Your Homebrew</title>
		<link>http://www.joshdale.net/2012/03/16/how-to-avoid-off-flavors-in-your-homebrew/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-avoid-off-flavors-in-your-homebrew</link>
		<comments>http://www.joshdale.net/2012/03/16/how-to-avoid-off-flavors-in-your-homebrew/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 03:48:08 +0000</pubDate>
		<dc:creator>Josh Dale</dc:creator>
				<category><![CDATA[Homebrew]]></category>
		<category><![CDATA[beer]]></category>
		<category><![CDATA[fermentation]]></category>
		<category><![CDATA[flavors]]></category>

		<guid isPermaLink="false">http://www.joshdale.net/?p=407</guid>
		<description><![CDATA[After enjoying a few bottles of my first batch of homebrew (an Imperial Amber Rye), I came to the conclusion that the beer was definitely enjoyable (who can complain, it&#8217;s your own damn beer), but not perfect. There are some &#8230; <a href="http://www.joshdale.net/2012/03/16/how-to-avoid-off-flavors-in-your-homebrew/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After enjoying a few bottles of my first batch of homebrew (an Imperial Amber Rye), I came to the conclusion that the beer was definitely enjoyable (who can complain, it&#8217;s your own damn beer), but not perfect.  There are some improvements that can be made to take the next batch to a new level.</p>
<p>I read some useful articles about off-flavors and after tastes that may affect the final flavor of your beer.  Certain brewing procedures may change the quality and taste characteristics (like dryness, bite, spice&#8230;etc). If something doesn&#8217;t taste right, then here are a few indicators and what may have caused them during the your brewing process&#8230;</p>
<p><span id="more-407"></span></p>
<h2>Acetaldehyde</h2>
<p><strong>After tastes/flavors:</strong>  a hint of green apples or a freshly cut pumpkin.</p>
<p>Acetaldehyde is a naturally forming compound produced by yeast in the fermentation process.  This generally means that the beer is too &#8220;young&#8221; and may need more time to condition.  So be patient, the beer isn&#8217;t quite ready to enjoy.</p>
<h2>Alcoholic</h2>
<p><strong>After tastes/flavors:</strong> overpowering, hot, spicy, or sharp alcohol flavor.</p>
<p>Fusel alcohols are produced at higher temperatures during the fermentation process, so if you pitch your yeast when the wort is higher than 80 degrees Fahrenheit, higher weight fusel alcohols are produced (harsh and bitter tasting).  You may also want to remove access sediment in your wort when starting primary fermentation.</p>
<h2>Astringent</h2>
<p><strong>After tastes/flavors:</strong> tart, puckering, dry, vinegary, and sometimes powdery.</p>
<p>This can be caused by steeping your grain in water that&#8217;s too hot, or if you&#8217;ve steeped for too long.  You want to make sure that your mash&#8217;s pH level is in between 5.2 &#8211; 5.6.  Also, leave the hops that cling to your fermentor out of your beer because of it&#8217;s bitter qualities.</p>
<h2>Cidery</h2>
<p><strong>After tastes/flavors:</strong> apple cider, acetaldehyde, or wine.</p>
<p>This is usually caused by using too much corn or sugar cane rather than liquid or dried malt extracts.  If you need more sugar for the carbonation process, you may want to try organic honey or syrups.</p>
<h2>Diacetyl</h2>
<p><strong>After tastes/flavors:</strong> buttery, butterscotch, smell of buttered popcorn.</p>
<p>Good for ales, bad for lagers.  This situation is difficult since yeast naturally produces this compound during fermentation.  A great indicator of whether or not your yeast is acting they way it should (bubbling and producing alcohol) is if it takes it a while to reach this state.  The longer the wait, the more diacetyl in your beer.</p>
<h2>Estery (Fruity)</h2>
<p><strong>After tastes/flavors:</strong> banana flavored, and not so prevalent: strawberry, grapefruit, or pear.</p>
<p>Again, this is naturally produced by yeast during fermentation, but yeast will produce more esters if fermented at a higher temperature.  If you taste banana, you may want to try to lower your temperature during fermentation.</p>
<h2>Grassy</h2>
<p><strong>After tastes/flavors:</strong> smells like freshly cut grassy, or moldy.</p>
<p>If you tastes these flavors, then your grain has grown mold or bacteria.  You need to store your grain in a cool, dry place.  If your grain is pre-milled, then make sure to use it within 2-4 weeks prior to milling.</p>
<p>Next time, I will continue this series with other common off-flavors.  And, by then I will be able to determine what after tastes are in my brew.</p>
<p>Check out these great sources: <a href="http://morebeer.com/content/homebrew-off-flavors" target="_blank">morebeer.com</a> and <a href="http://www.howtobrew.com/section4/chapter21-2.html" target="_blank">howtobrew.com</a>.  They both have great information if you&#8217;re starting to make your own damn beer.  Also, check out <a href="http://www.austinhomebrew.com" target="_blank">austinhomebrew.com</a> for beer kits, recipes, instruction, and anything homebrew.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshdale.net/2012/03/16/how-to-avoid-off-flavors-in-your-homebrew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hiding PullToRefreshListView Headers</title>
		<link>http://www.joshdale.net/2012/03/01/hiding-pulltorefreshlistview-headers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=hiding-pulltorefreshlistview-headers</link>
		<comments>http://www.joshdale.net/2012/03/01/hiding-pulltorefreshlistview-headers/#comments</comments>
		<pubDate>Thu, 01 Mar 2012 23:31:25 +0000</pubDate>
		<dc:creator>Josh Dale</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://www.joshdale.net/?p=296</guid>
		<description><![CDATA[Recently, I&#8217;ve been working with Johan Nilsson&#8217;s PullToRefreshListView library for a fancier ListView with refreshing functionality. It&#8217;s a great project, and its concepts are used by some big name applications including Facebook and Twitter (take a look at Chris Banes&#8217; &#8230; <a href="http://www.joshdale.net/2012/03/01/hiding-pulltorefreshlistview-headers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been working with <a href="http://github.com/johannilsson/android-pulltorefresh" target="_blank">Johan Nilsson&#8217;s</a> <code>PullToRefreshListView</code> library for a fancier <code>ListView</code> with refreshing functionality.  It&#8217;s a great project, and its concepts are used by some big name applications including Facebook and Twitter (take a look at Chris Banes&#8217; project on <a href="http://github.com/chrisbanes/Android-PullToRefresh" target="_blank">GitHub</a> too).</p>
<p>There was one limitation along the way that I decided to take matters into my own hands.  I needed to hide the &#8220;Tap to refresh&#8230;&#8221; header when there&#8217;s the same amount of visible items and total number of items in the list.  The only area I could see this information available to me was located in the <code>onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount)</code> method inherited by <code>OnScrollListener</code>.</p>
<p><span id="more-296"></span></p>
<p>I found out that this was a little trickier than it looked.  First, this is a hack and by no means the final implementation.  As of right now, this was the only thing I could think of that actually does what I expected it to do; hide the <code>ListView</code> header when the list doesn&#8217;t fill out its parent&#8217;s view.</p>
<p>Below is the first implementation of this workaround&#8230;</p>
<div id="gist-1953834" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="o">..</span></div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'><span class="nd">@Override</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="kd">public</span> <span class="kt">void</span> <span class="nf">onScroll</span><span class="o">(</span><span class="n">AbsListView</span> <span class="n">view</span><span class="o">,</span> <span class="kt">int</span> <span class="n">firstVisibleItem</span><span class="o">,</span> <span class="kt">int</span> <span class="n">visibleItemCount</span><span class="o">,</span> <span class="kt">int</span> <span class="n">totalItemCount</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">..</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span><span class="o">(</span><span class="n">mRefreshView</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	<span class="o">((</span><span class="n">LinearLayout</span><span class="o">)</span> <span class="n">mRefreshView</span><span class="o">.</span><span class="na">findViewById</span><span class="o">(</span><span class="n">R</span><span class="o">.</span><span class="na">id</span><span class="o">.</span><span class="na">hack1</span><span class="o">)).</span><span class="na">setVisibility</span><span class="o">(</span><span class="n">visibleItemCount</span> <span class="o">==</span> <span class="n">totalItemCount</span> <span class="o">?</span> <span class="n">View</span><span class="o">.</span><span class="na">GONE</span> <span class="o">:</span> <span class="n">View</span><span class="o">.</span><span class="na">VISIBLE</span><span class="o">);</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;		<span class="o">((</span><span class="n">LinearLayout</span><span class="o">)</span> <span class="n">mRefreshView</span><span class="o">.</span><span class="na">findViewById</span><span class="o">(</span><span class="n">R</span><span class="o">.</span><span class="na">id</span><span class="o">.</span><span class="na">hack2</span><span class="o">)).</span><span class="na">setVisibility</span><span class="o">(</span><span class="n">visibleItemCount</span> <span class="o">==</span> <span class="n">totalItemCount</span> <span class="o">?</span> <span class="n">View</span><span class="o">.</span><span class="na">GONE</span> <span class="o">:</span> <span class="n">View</span><span class="o">.</span><span class="na">VISIBLE</span><span class="o">);</span></div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;		</div><div class='line' id='LC11'>&nbsp;&nbsp;&nbsp;&nbsp;		<span class="o">((</span><span class="n">View</span><span class="o">)</span> <span class="n">mRefreshView</span><span class="o">.</span><span class="na">findViewById</span><span class="o">(</span><span class="n">R</span><span class="o">.</span><span class="na">id</span><span class="o">.</span><span class="na">hack3</span><span class="o">)).</span><span class="na">setVisibility</span><span class="o">(</span><span class="n">visibleItemCount</span> <span class="o">==</span> <span class="n">totalItemCount</span> <span class="o">?</span> <span class="n">View</span><span class="o">.</span><span class="na">GONE</span> <span class="o">:</span> <span class="n">View</span><span class="o">.</span><span class="na">VISIBLE</span><span class="o">);</span></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;		</div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;		<span class="n">mRefreshView</span><span class="o">.</span><span class="na">setVisibility</span><span class="o">(</span><span class="n">visibleItemCount</span> <span class="o">==</span> <span class="n">totalItemCount</span> <span class="o">?</span> <span class="n">View</span><span class="o">.</span><span class="na">GONE</span> <span class="o">:</span> <span class="n">View</span><span class="o">.</span><span class="na">VISIBLE</span><span class="o">);</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC15'><br/></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">..</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="o">}</span></div><div class='line' id='LC18'><br/></div><div class='line' id='LC19'><span class="o">..</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1953834/d5f60248819600fa622f6bdd9ea0e32f15c704f2/PullToRefreshListView.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1953834#file_pull_to_refresh_list_view.java" style="float:right;margin-right:10px;color:#666">PullToRefreshListView.java</a>
            <a href="https://gist.github.com/1953834">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>So, <code>mRefreshView</code> is the inflated <code>LinearLayout</code> for the <code>ListView</code> header; it has two orienting children (<code>LinearLayout</code>) and one <code>View</code>.  So, for this to work, you MUST declare <code>setVisibility(View.GONE)</code> for each child view.  If you don&#8217;t, the mechanism for drawing a <code>ListView</code> on your device&#8217;s screen renders each child&#8217;s layout parameters.  Don&#8217;t ask me why, because I have no idea&#8230;it just does <img src='http://www.joshdale.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>I hope this shed some light on the subject.  Take this with some considerations as it does check to see if the number of visible items are the same number of total items when you scroll your <code>ListView</code>.  I&#8217;m not seeing any memory leaks or issues right now, but they might manifest themselves if your logic is a bit beefier, so keep it light.  If anyone knows why a <code>ListView</code> header renders leftover views that are not set to <code>View.GONE</code>, please leave a comment!  Thanks and enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshdale.net/2012/03/01/hiding-pulltorefreshlistview-headers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Save Some Valuable Dev Time in XML Layouts</title>
		<link>http://www.joshdale.net/2012/02/24/save-some-valuable-dev-time-in-xml-layouts/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=save-some-valuable-dev-time-in-xml-layouts</link>
		<comments>http://www.joshdale.net/2012/02/24/save-some-valuable-dev-time-in-xml-layouts/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 17:46:09 +0000</pubDate>
		<dc:creator>Josh Dale</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[layout]]></category>
		<category><![CDATA[tip]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.joshdale.net/?p=198</guid>
		<description><![CDATA[First, I want to thank Luke Wendling, fellow co-worker here at Bypass Lane, for this brilliant suggestion. So, when creating your XML layouts in your project, have you ever asked yourself, &#8220;why do I have to type android: every time &#8230; <a href="http://www.joshdale.net/2012/02/24/save-some-valuable-dev-time-in-xml-layouts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>First, I want to thank <a href="http://lukewendling.com" target="_blank">Luke Wendling</a>, fellow co-worker here at <a href="http://bypasslane.com" target="_blank">Bypass Lane</a>, for this brilliant suggestion.</p>
<p>So, when creating your XML layouts in your project, have you ever asked yourself, &#8220;why do I have to type <code>android:</code> every time I declare an attribute?&#8221;</p>
<p>Well, the short answer is, <strong>YOU DON&#8217;T HAVE TO USE ANDROID: EVERYTIME!</strong> You can change the <code>xmlns:android</code> namespace declaration to whatever prefix you want. Please, take a look below to see how you can implement this in your next project.</p>
<h3>Old Declaration</h3>
<p><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"... /&gt;</code><br />
<code>&lt;TextView android:layout_width="fill_parent"... /&gt;</code></p>
<p><span id="more-198"></span></p>
<h3>New Declaration</h3>
<p><code>&lt;LinearLayout xmlns:a="http://schemas.android.com/apk/res/android"... /&gt;</code><br />
<code>&lt;TextView a:layout_width="fill_parent"... /&gt;</code></p>
<p>If you want the long answer, here&#8217;s the magic of <a href="http://en.wikipedia.org/wiki/Xml_namespace" target="_blank">Wikipedia</a>. Essentially, you are referencing a variable <code>android</code> to the Android specific namespace, <code>http://schemas.android.com/apk/res/android</code>.  You can declare any variable name you want.  You&#8217;ve now reduced the time it takes to type &#8220;<i>android</i>&#8221; by more than 85% when declaring a single letter variable for your namespace attributes.</p>
<p>For those of you that want to retrofit this suggestion in your existing projects, here&#8217;s a quick couple of steps you can follow to clean up your namespaces.</p>
<ul>
<li>Step #1: Open up a layout file.</li>
<li>Step #2: Change the &#8220;xmlns:android&#8221; namespace declaration to desired prefix (e.g., xmlns:a).</li>
<li>Step #3: Change all occurrences of &#8220;android:&#8221; in your layout file to your new prefix (e.g., a:).</li>
<li>Step #4: Repeat for all layout files you want to adjust.</li>
</ul>
<p>And, there you have it fellow dev machines.  This will save you time and money in the long run.  Happy deving!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshdale.net/2012/02/24/save-some-valuable-dev-time-in-xml-layouts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionBar Design Patterns on Pre-API 11 Devices</title>
		<link>http://www.joshdale.net/2012/01/31/actionbar-design-patterns-on-pre-api-11-devices/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=actionbar-design-patterns-on-pre-api-11-devices</link>
		<comments>http://www.joshdale.net/2012/01/31/actionbar-design-patterns-on-pre-api-11-devices/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 16:26:56 +0000</pubDate>
		<dc:creator>Josh Dale</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[actionbar]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[sdk]]></category>

		<guid isPermaLink="false">http://www.joshdale.net/?p=104</guid>
		<description><![CDATA[The folks over at Android Developers have released some sample code to implement Action Bar design patterns for pre-API 11 devices. The code and concepts have been around for some time now, and many developers have been implementing 3rd-party libraries &#8230; <a href="http://www.joshdale.net/2012/01/31/actionbar-design-patterns-on-pre-api-11-devices/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The folks over at <a href="http://developer.android.com/resources/samples/ActionBarCompat/index.html" target="_blank">Android Developers</a> have released some sample code to implement Action Bar design patterns for pre-API 11 devices. The code and concepts have been around for some time now, and many developers have been implementing 3rd-party libraries to achieve this goal (<a href="http://actionbarsherlock.com/" target="_blank">ActionBarSherlock</a> and <a href="https://github.com/cyrilmottier/GreenDroid" target="_blank">GreenDroid</a>). Now with the latest code release of Android, Ice Cream Sandwich, developers need to consider <a href="http://developer.android.com/design/patterns/actionbar.html" target="_blank">standardized design</a> elements across all API levels.</p>
<p>The main goal of the ActionBar is to provide vital information to the user about your application. This is also a great place to use your icon or logo for brand recognition and consistent navigations throughout the app. Now the user subliminally thinks about your logo as a specific navigational action. If the user needs to return to the home screen in the app, they have to visualize your brand.</p>
<p><span id="more-104"></span></p>
<p>So, how do you implement ActionBarCompat? You will need to make sure that the target SDK level is at least 11 in your <em>AndroidManifest.xml</em>:</p>
<div id="gist-1724361" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="nt">&lt;manifest</span> <span class="err">...</span> <span class="nt">&gt;</span></div><div class='line' id='LC2'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;uses-sdk</span> <span class="na">android:minSdkVersion=</span><span class="s">&quot;4&quot;</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="na">android:targetSdkVersion=</span><span class="s">&quot;11&quot;</span> <span class="nt">/&gt;</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;...</div><div class='line' id='LC5'><span class="nt">&lt;/manifest&gt;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1724361/12eb69a1aa1ca121779eece0458ac8926437da8c/AndroidManifest.xml" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1724361#file_android_manifest.xml" style="float:right;margin-right:10px;color:#666">AndroidManifest.xml</a>
            <a href="https://gist.github.com/1724361">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>When you declare this in your manifest, the Android SDK and the ActionBarCompat library project will utilize native declarations for devices greater than API 11.</p>
<p>Next, include these files in your project (create a new package including these classes):</p>
<ul class="nolist">
<li><a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/ActionBarActivity.html" target="_blank">ActionBarActivity.java</a></li>
<li><a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/ActionBarHelper.html" target="_blank">ActionBarHelper.java</a></li>
<li><a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/ActionBarHelperBase.html" target="_blank">ActionBarHelperBase.java</a></li>
<li><a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/ActionBarHelperHoneycomb.html" target="_blank">ActionBarHelperHoneycomb.java</a></li>
<li><a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/ActionBarHelperICS.html" target="_blank">ActionBarHelperICS.java</a></li>
<li><a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/MainActivity.html" target="_blank">MainActivity.java</a></li>
<li><a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/SimpleMenu.html" target="_blank">SimpleMenu.java</a></li>
<li><a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/SimpleMenuItem.html" target="_blank">SimpleMenuItem.java</a></li>
</ul>
<p>If you take a closer look at <a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/MainActivity.html" target="_blank"><i>MainActivity.java</i></a>, you can see that this activity extends the ActionBarActivity class.  In <a href="http://developer.android.com/resources/samples/ActionBarCompat/src/com/example/android/actionbarcompat/ActionBarActivity.html" target="_blank"><i>ActionBarActivity.java</i></a>, this class extends the Activity class that we all know and love.  What&#8217;s great about this particular class is that it does all the heavy lifting for us to utilize the title bar as a pseudo-ActionBar.</p>
<p>You will need to makes sure that you are importing the available <a href="http://developer.android.com/resources/samples/ActionBarCompat/res/index.html" target="_blank"><i>/res</i></a> folders.  In that folder, you will see layouts covering all API levels (including ICS).  You can take a look at the <a href="http://developer.android.com/resources/samples/ActionBarCompat/res/values/index.html" target="_blank"><i>/res/values</i></a> folder and make necessary adjustments for styling and height dimensions on pre-API 11 devices.</p>
<p>So, that&#8217;s the 50,000 foot view of this project.  Make sure that you&#8217;ve included all these files in you project and make the necessary adjustments tailored for you application.  If you have any other questions, or something&#8217;s not working correctly, please leave a comment.  Also, take a look at this project in much greater detail at <a href="http://developer.android.com/resources/samples/ActionBarCompat/index.html" target="_blank">Android Developers</a>.</p>
<p>It&#8217;s great that <a href="http://source.android.com/" target="_blank">AOSP</a> is available to all developers and can be implemented in all your future projects; just make sure you provide credit where credit is due.  Please take advantage of what Android Developers provides for us devs.  Happy deving!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshdale.net/2012/01/31/actionbar-design-patterns-on-pre-api-11-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Everybody Loves Vibrating Toasts</title>
		<link>http://www.joshdale.net/2011/12/30/everybody-loves-vibrating-toasts/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=everybody-loves-vibrating-toasts</link>
		<comments>http://www.joshdale.net/2011/12/30/everybody-loves-vibrating-toasts/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 16:35:47 +0000</pubDate>
		<dc:creator>Josh Dale</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[snippet]]></category>
		<category><![CDATA[toast]]></category>

		<guid isPermaLink="false">http://www.joshdale.net/?p=83</guid>
		<description><![CDATA[I came across an interesting idea on stackoverflow.com for Toast notifications on Android. It&#8217;s a simple class that extends Toast. We will modify the constructor to vibrate your device when this new Toast is displayed on screen. Below is the &#8230; <a href="http://www.joshdale.net/2011/12/30/everybody-loves-vibrating-toasts/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I came across an interesting idea on <a href="http://stackoverflow.com/questions/4206675/android-vibrate-on-toast-homer-mmmm-vibrate-on-toast" target="_blank">stackoverflow.com</a> for Toast notifications on Android.</p>
<p>It&#8217;s a simple class that extends Toast.  We will modify the constructor to vibrate your device when this new Toast is displayed on screen.  Below is the ~5 lined class:</p>
<div id="gist-1540485" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">VibratingToast</span> <span class="kd">extends</span> <span class="n">Toast</span> <span class="o">{</span></div><div class='line' id='LC2'>	<span class="kd">public</span> <span class="nf">VibratingToast</span><span class="o">(</span><span class="n">Context</span> <span class="n">context</span><span class="o">,</span> <span class="n">CharSequence</span> <span class="n">text</span><span class="o">,</span> <span class="kt">int</span> <span class="n">duration</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC3'>		<span class="kd">super</span><span class="o">(</span><span class="n">context</span><span class="o">);</span></div><div class='line' id='LC4'><br/></div><div class='line' id='LC5'>		<span class="o">((</span><span class="n">Vibrator</span><span class="o">)</span> <span class="n">context</span><span class="o">.</span><span class="na">getSystemService</span><span class="o">(</span><span class="n">Context</span><span class="o">.</span><span class="na">VIBRATOR_SERVICE</span><span class="o">)).</span><span class="na">vibrate</span><span class="o">(</span><span class="mi">300</span><span class="o">);</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'>		<span class="kd">super</span><span class="o">.</span><span class="na">makeText</span><span class="o">(</span><span class="n">context</span><span class="o">,</span> <span class="n">text</span><span class="o">,</span> <span class="n">duration</span><span class="o">).</span><span class="na">show</span><span class="o">();</span></div><div class='line' id='LC8'>	<span class="o">}</span></div><div class='line' id='LC9'><span class="o">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1540485/80a614f75e49f4a7c2970db9f38e6d97c5057929/VibratingToast.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1540485#file_vibrating_toast.java" style="float:right;margin-right:10px;color:#666">VibratingToast.java</a>
            <a href="https://gist.github.com/1540485">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p><span id="more-83"></span></p>
<p>Now all you have to do is call your new Toast when you want some vibrations:</p>
<p><code>new VibratingToast(getApplicationContext(), "some message that needs vibrations...", Toast.LENGTH_LONG);</code></p>
<p>And, don&#8217;t forget that you will need to declare vibrating permission in your <em>AndroidManifest.xml</em>:</p>
<p><code>&lt;uses-permission android:name="android.permission.VIBRATE" /&gt;</code></p>
<p>Easy and simple!  Happy deving!!!</p>
<p>P.S. &#8211; if you want to get fancy and add another parameter to our constructor to accept a vibrating duration integer, please leave a comment or snippet on <a href="https://gist.github.com/1540485" target="_blank">gist.github.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.joshdale.net/2011/12/30/everybody-loves-vibrating-toasts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RESTclient for Blackberry</title>
		<link>http://www.joshdale.net/2011/10/29/restclient-for-blackberry/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=restclient-for-blackberry</link>
		<comments>http://www.joshdale.net/2011/10/29/restclient-for-blackberry/#comments</comments>
		<pubDate>Sat, 29 Oct 2011 18:32:16 +0000</pubDate>
		<dc:creator>Josh Dale</dc:creator>
				<category><![CDATA[Blackberry]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rest client]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://www.joshdale.net/?p=35</guid>
		<description><![CDATA[Recently, I&#8217;ve ventured out into the Blackberry app development space and found that some documentation is lacking for developers to create awesome applications for that platform. After searching around Google, Stack Overflow, and RIM&#8217;s developer zone, I came to the &#8230; <a href="http://www.joshdale.net/2011/10/29/restclient-for-blackberry/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve ventured out into the Blackberry app development space and found that some documentation is lacking for developers to create awesome applications for that platform. After searching around Google, Stack Overflow, and RIM&#8217;s developer zone, I came to the conclusion that there isn&#8217;t any good examples of how to implement a REST client effectively in a Blackberry Java-based environment.</p>
<p>REST clients are a mobile app developers best friend. They allow developers to make lightweight network calls to useful APIs such as the Graph API, Twitter&#8217;s API, and Google&#8217;s family of APIs including Maps, Google+, and Youtube. I came across a great example, <a href="http://www.appstoreblog.com/2011/05/22/restclient-for-android/" target="_blank">RESTclient for Android</a> by Tyler Smith, and used this implementation to create a foundation for a Blackberry REST client.</p>
<p><span id="more-35"></span></p>
<p>Introducing <a href="https://gist.github.com/1324853" target="_blank">RESTclient for Blackberry</a> with basic authentication and JSON body posting (notice that this implementation only utilizes the REST verbs GET and POST):</p>
<div id="gist-1324853" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">RestClient</span> <span class="o">{</span></div><div class='line' id='LC2'>	<span class="kd">private</span> <span class="n">String</span> <span class="n">_url</span><span class="o">;</span></div><div class='line' id='LC3'><br/></div><div class='line' id='LC4'>	<span class="kd">private</span> <span class="n">Vector</span> <span class="n">_headers</span><span class="o">;</span></div><div class='line' id='LC5'>	<span class="kd">private</span> <span class="n">Vector</span> <span class="n">_params</span><span class="o">;</span></div><div class='line' id='LC6'><br/></div><div class='line' id='LC7'>	<span class="kd">private</span> <span class="n">String</span> <span class="n">_json</span><span class="o">;</span></div><div class='line' id='LC8'><br/></div><div class='line' id='LC9'>	<span class="kd">private</span> <span class="kt">int</span> <span class="n">_response_code</span><span class="o">;</span></div><div class='line' id='LC10'>	<span class="kd">private</span> <span class="n">String</span> <span class="n">_response</span><span class="o">;</span></div><div class='line' id='LC11'><br/></div><div class='line' id='LC12'>	<span class="kd">private</span> <span class="kt">boolean</span> <span class="n">_authentication</span> <span class="o">=</span> <span class="kc">false</span><span class="o">;</span></div><div class='line' id='LC13'>	<span class="kd">private</span> <span class="n">String</span> <span class="n">_username</span><span class="o">;</span></div><div class='line' id='LC14'>	<span class="kd">private</span> <span class="n">String</span> <span class="n">_password</span><span class="o">;</span></div><div class='line' id='LC15'><br/></div><div class='line' id='LC16'>	<span class="kd">public</span> <span class="nf">RestClient</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC17'>		<span class="n">_url</span> <span class="o">=</span> <span class="kc">null</span><span class="o">;</span></div><div class='line' id='LC18'><br/></div><div class='line' id='LC19'>		<span class="n">_headers</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Vector</span><span class="o">();</span></div><div class='line' id='LC20'>		<span class="n">_params</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Vector</span><span class="o">();</span></div><div class='line' id='LC21'>	<span class="o">}</span></div><div class='line' id='LC22'><br/></div><div class='line' id='LC23'>	<span class="kd">public</span> <span class="nf">RestClient</span><span class="o">(</span><span class="n">String</span> <span class="n">url</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC24'>		<span class="n">_url</span> <span class="o">=</span> <span class="n">url</span><span class="o">;</span></div><div class='line' id='LC25'><br/></div><div class='line' id='LC26'>		<span class="n">_headers</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Vector</span><span class="o">();</span></div><div class='line' id='LC27'>		<span class="n">_params</span> <span class="o">=</span> <span class="k">new</span> <span class="n">Vector</span><span class="o">();</span></div><div class='line' id='LC28'>	<span class="o">}</span></div><div class='line' id='LC29'><br/></div><div class='line' id='LC30'>	<span class="kd">public</span> <span class="kt">void</span> <span class="nf">addBasicAuth</span><span class="o">(</span><span class="n">String</span> <span class="n">username</span><span class="o">,</span> <span class="n">String</span> <span class="n">password</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC31'>		<span class="n">_authentication</span> <span class="o">=</span> <span class="kc">true</span><span class="o">;</span></div><div class='line' id='LC32'><br/></div><div class='line' id='LC33'>		<span class="n">_username</span> <span class="o">=</span> <span class="n">username</span><span class="o">;</span></div><div class='line' id='LC34'>		<span class="n">_password</span> <span class="o">=</span> <span class="n">password</span><span class="o">;</span></div><div class='line' id='LC35'>	<span class="o">}</span></div><div class='line' id='LC36'><br/></div><div class='line' id='LC37'>	<span class="kd">public</span> <span class="kt">void</span> <span class="nf">addHeader</span><span class="o">(</span><span class="n">String</span> <span class="n">name</span><span class="o">,</span> <span class="n">String</span> <span class="n">value</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC38'>		<span class="n">_headers</span><span class="o">.</span><span class="na">addElement</span><span class="o">(</span><span class="k">new</span> <span class="n">NameValuePair</span><span class="o">(</span><span class="n">name</span><span class="o">,</span> <span class="n">value</span><span class="o">));</span></div><div class='line' id='LC39'>	<span class="o">}</span></div><div class='line' id='LC40'><br/></div><div class='line' id='LC41'>	<span class="kd">public</span> <span class="kt">void</span> <span class="nf">addParam</span><span class="o">(</span><span class="n">String</span> <span class="n">name</span><span class="o">,</span> <span class="n">String</span> <span class="n">value</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC42'>		<span class="n">_params</span><span class="o">.</span><span class="na">addElement</span><span class="o">(</span><span class="k">new</span> <span class="n">NameValuePair</span><span class="o">(</span><span class="n">name</span><span class="o">,</span> <span class="n">value</span><span class="o">));</span></div><div class='line' id='LC43'>	<span class="o">}</span></div><div class='line' id='LC44'><br/></div><div class='line' id='LC45'>	<span class="kd">public</span> <span class="kt">void</span> <span class="nf">execute</span><span class="o">(</span><span class="kt">int</span> <span class="n">method</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span></div><div class='line' id='LC46'>		<span class="k">switch</span><span class="o">(</span><span class="n">method</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC47'>		<span class="k">case</span> <span class="n">RestMethod</span><span class="o">.</span><span class="na">GET</span><span class="o">:</span> <span class="o">{</span></div><div class='line' id='LC48'>			<span class="n">HttpsConnection</span> <span class="n">request</span> <span class="o">=</span> <span class="o">(</span><span class="n">HttpsConnection</span><span class="o">)</span> <span class="n">Connector</span><span class="o">.</span><span class="na">open</span><span class="o">(</span><span class="n">_url</span> <span class="o">+</span> <span class="n">addGetParams</span><span class="o">());</span></div><div class='line' id='LC49'>			<span class="n">request</span><span class="o">.</span><span class="na">setRequestMethod</span><span class="o">(</span><span class="n">HttpConnection</span><span class="o">.</span><span class="na">GET</span><span class="o">);</span></div><div class='line' id='LC50'>			<span class="n">addHeaderParams</span><span class="o">(</span><span class="n">request</span><span class="o">);</span></div><div class='line' id='LC51'><br/></div><div class='line' id='LC52'>			<span class="n">executeRequest</span><span class="o">(</span><span class="n">request</span><span class="o">);</span></div><div class='line' id='LC53'>			<span class="k">break</span><span class="o">;</span></div><div class='line' id='LC54'>		<span class="o">}</span></div><div class='line' id='LC55'>		<span class="k">case</span> <span class="n">RestMethod</span><span class="o">.</span><span class="na">POST</span><span class="o">:</span> <span class="o">{</span></div><div class='line' id='LC56'>			<span class="n">HttpsConnection</span> <span class="n">request</span> <span class="o">=</span> <span class="o">(</span><span class="n">HttpsConnection</span><span class="o">)</span> <span class="n">Connector</span><span class="o">.</span><span class="na">open</span><span class="o">(</span><span class="n">_url</span><span class="o">);</span></div><div class='line' id='LC57'>			<span class="n">request</span><span class="o">.</span><span class="na">setRequestMethod</span><span class="o">(</span><span class="n">HttpConnection</span><span class="o">.</span><span class="na">POST</span><span class="o">);</span></div><div class='line' id='LC58'>			<span class="n">addHeaderParams</span><span class="o">(</span><span class="n">request</span><span class="o">);</span></div><div class='line' id='LC59'>			<span class="n">addBodyParams</span><span class="o">(</span><span class="n">request</span><span class="o">);</span></div><div class='line' id='LC60'><br/></div><div class='line' id='LC61'>			<span class="n">executeRequest</span><span class="o">(</span><span class="n">request</span><span class="o">);</span></div><div class='line' id='LC62'>			<span class="k">break</span><span class="o">;</span></div><div class='line' id='LC63'>		<span class="o">}</span></div><div class='line' id='LC64'>		<span class="o">}</span></div><div class='line' id='LC65'>	<span class="o">}</span></div><div class='line' id='LC66'><br/></div><div class='line' id='LC67'>	<span class="kd">private</span> <span class="kt">void</span> <span class="nf">addHeaderParams</span><span class="o">(</span><span class="n">HttpsConnection</span> <span class="n">request</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span></div><div class='line' id='LC68'>		<span class="k">for</span><span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">_headers</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span></div><div class='line' id='LC69'>			<span class="n">request</span><span class="o">.</span><span class="na">setRequestProperty</span><span class="o">(((</span><span class="n">NameValuePair</span><span class="o">)</span> <span class="n">_headers</span><span class="o">.</span><span class="na">elementAt</span><span class="o">(</span><span class="n">i</span><span class="o">)).</span><span class="na">getName</span><span class="o">(),</span> <span class="o">((</span><span class="n">NameValuePair</span><span class="o">)</span> <span class="n">_headers</span><span class="o">.</span><span class="na">elementAt</span><span class="o">(</span><span class="n">i</span><span class="o">)).</span><span class="na">getValue</span><span class="o">());</span></div><div class='line' id='LC70'>		<span class="o">}</span></div><div class='line' id='LC71'><br/></div><div class='line' id='LC72'>		<span class="k">if</span><span class="o">(</span><span class="n">_authentication</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC73'>			<span class="kt">byte</span><span class="o">[]</span> <span class="n">cred</span> <span class="o">=</span> <span class="n">Base64OutputStream</span><span class="o">.</span><span class="na">encode</span><span class="o">((</span><span class="n">_username</span> <span class="o">+</span> <span class="s">&quot;:&quot;</span> <span class="o">+</span> <span class="n">_password</span><span class="o">).</span><span class="na">getBytes</span><span class="o">(</span><span class="s">&quot;UTF-8&quot;</span><span class="o">),</span> <span class="mi">0</span><span class="o">,</span> <span class="o">(</span><span class="n">_username</span> <span class="o">+</span> <span class="s">&quot;:&quot;</span> <span class="o">+</span> <span class="n">_password</span><span class="o">).</span><span class="na">length</span><span class="o">(),</span> <span class="kc">false</span><span class="o">,</span> <span class="kc">false</span><span class="o">);</span></div><div class='line' id='LC74'><br/></div><div class='line' id='LC75'>			<span class="n">request</span><span class="o">.</span><span class="na">setRequestProperty</span><span class="o">(</span><span class="s">&quot;Authorization&quot;</span><span class="o">,</span> <span class="s">&quot;Basic &quot;</span> <span class="o">+</span> <span class="k">new</span> <span class="n">String</span><span class="o">(</span><span class="n">cred</span><span class="o">).</span><span class="na">toString</span><span class="o">());</span></div><div class='line' id='LC76'>		<span class="o">}</span></div><div class='line' id='LC77'>	<span class="o">}</span></div><div class='line' id='LC78'><br/></div><div class='line' id='LC79'>	<span class="kd">private</span> <span class="kt">void</span> <span class="nf">addBodyParams</span><span class="o">(</span><span class="n">HttpsConnection</span> <span class="n">request</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span></div><div class='line' id='LC80'>		<span class="k">if</span><span class="o">(</span><span class="n">_json</span> <span class="o">!=</span> <span class="kc">null</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC81'>			<span class="kt">byte</span><span class="o">[]</span> <span class="n">data</span> <span class="o">=</span> <span class="n">_json</span><span class="o">.</span><span class="na">getBytes</span><span class="o">(</span><span class="s">&quot;UTF-8&quot;</span><span class="o">);</span></div><div class='line' id='LC82'><br/></div><div class='line' id='LC83'>			<span class="n">request</span><span class="o">.</span><span class="na">setRequestProperty</span><span class="o">(</span><span class="s">&quot;Content-Type&quot;</span><span class="o">,</span> <span class="s">&quot;application/json&quot;</span><span class="o">);</span></div><div class='line' id='LC84'>			<span class="n">request</span><span class="o">.</span><span class="na">setRequestProperty</span><span class="o">(</span><span class="s">&quot;Content-Length&quot;</span><span class="o">,</span> <span class="n">String</span><span class="o">.</span><span class="na">valueOf</span><span class="o">(</span><span class="n">data</span><span class="o">.</span><span class="na">length</span><span class="o">));</span></div><div class='line' id='LC85'><br/></div><div class='line' id='LC86'>			<span class="n">OutputStream</span> <span class="n">os</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="na">openDataOutputStream</span><span class="o">();</span></div><div class='line' id='LC87'><br/></div><div class='line' id='LC88'>			<span class="n">os</span><span class="o">.</span><span class="na">write</span><span class="o">(</span><span class="n">data</span><span class="o">);</span></div><div class='line' id='LC89'>			<span class="n">os</span><span class="o">.</span><span class="na">flush</span><span class="o">();</span></div><div class='line' id='LC90'>			<span class="n">os</span><span class="o">.</span><span class="na">close</span><span class="o">();</span></div><div class='line' id='LC91'>		<span class="o">}</span></div><div class='line' id='LC92'>	<span class="o">}</span></div><div class='line' id='LC93'><br/></div><div class='line' id='LC94'>	<span class="kd">private</span> <span class="n">String</span> <span class="nf">addGetParams</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">Exception</span> <span class="o">{</span>		</div><div class='line' id='LC95'>		<span class="n">StringBuffer</span> <span class="n">buff</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StringBuffer</span><span class="o">();</span></div><div class='line' id='LC96'>		<span class="k">if</span><span class="o">(!</span><span class="n">_params</span><span class="o">.</span><span class="na">isEmpty</span><span class="o">())</span> <span class="o">{</span></div><div class='line' id='LC97'>			<span class="n">buff</span><span class="o">.</span><span class="na">append</span><span class="o">(</span><span class="s">&quot;?&quot;</span><span class="o">);</span></div><div class='line' id='LC98'><br/></div><div class='line' id='LC99'>			<span class="k">for</span><span class="o">(</span><span class="kt">int</span> <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span> <span class="n">i</span> <span class="o">&lt;</span> <span class="n">_params</span><span class="o">.</span><span class="na">size</span><span class="o">();</span> <span class="n">i</span><span class="o">++)</span> <span class="o">{</span></div><div class='line' id='LC100'>				<span class="n">buff</span><span class="o">.</span><span class="na">append</span><span class="o">(</span><span class="n">_params</span><span class="o">.</span><span class="na">size</span><span class="o">()</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="o">?</span> <span class="s">&quot;&amp;&quot;</span> <span class="o">:</span> <span class="s">&quot;&quot;</span> <span class="o">+</span> <span class="o">((</span><span class="n">NameValuePair</span><span class="o">)</span> <span class="n">_params</span><span class="o">.</span><span class="na">elementAt</span><span class="o">(</span><span class="n">i</span><span class="o">)).</span><span class="na">getName</span><span class="o">()</span> <span class="o">+</span> <span class="o">((</span><span class="n">NameValuePair</span><span class="o">)</span> <span class="n">_params</span><span class="o">.</span><span class="na">elementAt</span><span class="o">(</span><span class="n">i</span><span class="o">)).</span><span class="na">getValue</span><span class="o">());</span></div><div class='line' id='LC101'>			<span class="o">}</span></div><div class='line' id='LC102'>		<span class="o">}</span></div><div class='line' id='LC103'><br/></div><div class='line' id='LC104'>		<span class="k">return</span> <span class="n">buff</span><span class="o">.</span><span class="na">toString</span><span class="o">();</span></div><div class='line' id='LC105'>	<span class="o">}</span></div><div class='line' id='LC106'><br/></div><div class='line' id='LC107'>	<span class="kd">public</span> <span class="kt">int</span> <span class="nf">getResponseCode</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC108'>		<span class="k">return</span> <span class="n">_response_code</span><span class="o">;</span></div><div class='line' id='LC109'>	<span class="o">}</span></div><div class='line' id='LC110'><br/></div><div class='line' id='LC111'>	<span class="kd">public</span> <span class="n">String</span> <span class="nf">getResponse</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC112'>		<span class="k">return</span> <span class="n">_response</span><span class="o">;</span></div><div class='line' id='LC113'>	<span class="o">}</span></div><div class='line' id='LC114'><br/></div><div class='line' id='LC115'>	<span class="kd">public</span> <span class="kt">void</span> <span class="nf">setURL</span><span class="o">(</span><span class="n">String</span> <span class="n">url</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC116'>		<span class="n">_url</span> <span class="o">=</span> <span class="n">url</span><span class="o">;</span></div><div class='line' id='LC117'>	<span class="o">}</span></div><div class='line' id='LC118'><br/></div><div class='line' id='LC119'>	<span class="kd">public</span> <span class="kt">void</span> <span class="nf">setJSONString</span><span class="o">(</span><span class="n">String</span> <span class="n">json</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC120'>		<span class="n">_json</span> <span class="o">=</span> <span class="n">json</span><span class="o">;</span></div><div class='line' id='LC121'>	<span class="o">}</span></div><div class='line' id='LC122'><br/></div><div class='line' id='LC123'>	<span class="kd">private</span> <span class="kt">void</span> <span class="nf">executeRequest</span><span class="o">(</span><span class="n">HttpsConnection</span> <span class="n">request</span><span class="o">)</span> <span class="o">{</span>		</div><div class='line' id='LC124'>		<span class="k">try</span> <span class="o">{</span></div><div class='line' id='LC125'>			<span class="n">_response_code</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="na">getResponseCode</span><span class="o">();</span></div><div class='line' id='LC126'><br/></div><div class='line' id='LC127'>			<span class="k">if</span><span class="o">(</span><span class="n">_response_code</span> <span class="o">==</span> <span class="n">HttpsConnection</span><span class="o">.</span><span class="na">HTTP_OK</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC128'>				<span class="n">InputStream</span> <span class="n">is</span> <span class="o">=</span> <span class="n">request</span><span class="o">.</span><span class="na">openInputStream</span><span class="o">();</span></div><div class='line' id='LC129'><br/></div><div class='line' id='LC130'>				<span class="kt">int</span> <span class="n">len</span> <span class="o">=</span> <span class="o">(</span><span class="kt">int</span><span class="o">)</span> <span class="n">request</span><span class="o">.</span><span class="na">getLength</span><span class="o">();</span></div><div class='line' id='LC131'>				<span class="k">if</span><span class="o">(</span><span class="n">len</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC132'>					<span class="kt">int</span> <span class="n">actual</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span></div><div class='line' id='LC133'>					<span class="kt">int</span> <span class="n">read</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span></div><div class='line' id='LC134'>					<span class="kt">byte</span><span class="o">[]</span> <span class="n">data</span> <span class="o">=</span> <span class="k">new</span> <span class="kt">byte</span><span class="o">[</span><span class="n">len</span><span class="o">];</span></div><div class='line' id='LC135'>					<span class="k">while</span><span class="o">((</span><span class="n">read</span> <span class="o">!=</span> <span class="n">len</span><span class="o">)</span> <span class="o">&amp;&amp;</span> <span class="o">(</span><span class="n">actual</span> <span class="o">!=</span> <span class="o">-</span><span class="mi">1</span><span class="o">))</span> <span class="o">{</span></div><div class='line' id='LC136'>						<span class="n">actual</span> <span class="o">=</span> <span class="n">is</span><span class="o">.</span><span class="na">read</span><span class="o">(</span><span class="n">data</span><span class="o">,</span> <span class="n">read</span><span class="o">,</span> <span class="n">len</span> <span class="o">-</span> <span class="n">read</span><span class="o">);</span></div><div class='line' id='LC137'>						<span class="n">read</span> <span class="o">+=</span> <span class="n">actual</span><span class="o">;</span></div><div class='line' id='LC138'>					<span class="o">}</span></div><div class='line' id='LC139'><br/></div><div class='line' id='LC140'>					<span class="n">_response</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">(</span><span class="n">data</span><span class="o">).</span><span class="na">toString</span><span class="o">();</span></div><div class='line' id='LC141'>				<span class="o">}</span></div><div class='line' id='LC142'><br/></div><div class='line' id='LC143'>				<span class="n">is</span><span class="o">.</span><span class="na">close</span><span class="o">();</span></div><div class='line' id='LC144'><br/></div><div class='line' id='LC145'>				<span class="n">_params</span><span class="o">.</span><span class="na">removeAllElements</span><span class="o">();</span></div><div class='line' id='LC146'>				<span class="n">_headers</span><span class="o">.</span><span class="na">removeAllElements</span><span class="o">();</span></div><div class='line' id='LC147'>			<span class="o">}</span></div><div class='line' id='LC148'>		<span class="o">}</span> <span class="k">catch</span> <span class="o">(</span><span class="n">Exception</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC149'>			<span class="n">e</span><span class="o">.</span><span class="na">printStackTrace</span><span class="o">();</span></div><div class='line' id='LC150'>		<span class="o">}</span></div><div class='line' id='LC151'>	<span class="o">}</span></div><div class='line' id='LC152'><span class="o">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1324853/c19bf8f6da2a4d40cc6a496af7cf6c3417766a17/RestClient.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1324853#file_rest_client.java" style="float:right;margin-right:10px;color:#666">RestClient.java</a>
            <a href="https://gist.github.com/1324853">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>Take a look at this snippet of code&#8230;</p>
<p><code>public void execute(int method) throws Exception { .. }</code></p>
<p>We define <em>int method</em> by invoking the RestMethod class:</p>
<div id="gist-1324853" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">RestMethod</span> <span class="o">{</span></div><div class='line' id='LC2'>	<span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="kt">int</span> <span class="n">GET</span> <span class="o">=</span> <span class="mi">0</span><span class="o">;</span></div><div class='line' id='LC3'>	<span class="kd">public</span> <span class="kd">static</span> <span class="kd">final</span> <span class="kt">int</span> <span class="n">POST</span> <span class="o">=</span> <span class="mi">1</span><span class="o">;</span></div><div class='line' id='LC4'><span class="o">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1324853/63aa1006ec351eb44d34d9f60ed3bac30db75677/RestMethod.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1324853#file_rest_method.java" style="float:right;margin-right:10px;color:#666">RestMethod.java</a>
            <a href="https://gist.github.com/1324853">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p>And there you have it. If you have anything else to contribute, please feel free to comment below. Thanks to Tyler Smith, and the other contributors for this evolving code. Happy deving!</p>
<p><strong>UPDATE:</strong></p>
<p>And the NameValuePair class:</p>
<div id="gist-1324853" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kd">public</span> <span class="kd">class</span> <span class="nc">NameValuePair</span> <span class="o">{</span></div><div class='line' id='LC2'>	<span class="kd">private</span> <span class="n">String</span> <span class="n">_name</span><span class="o">;</span></div><div class='line' id='LC3'>	<span class="kd">private</span> <span class="n">String</span> <span class="n">_value</span><span class="o">;</span></div><div class='line' id='LC4'><br/></div><div class='line' id='LC5'>	<span class="kd">public</span> <span class="nf">NameValuePair</span><span class="o">(</span><span class="n">String</span> <span class="n">name</span><span class="o">,</span> <span class="n">String</span> <span class="n">value</span><span class="o">)</span> <span class="o">{</span></div><div class='line' id='LC6'>		<span class="n">_name</span> <span class="o">=</span> <span class="n">name</span><span class="o">;</span></div><div class='line' id='LC7'>		<span class="n">_value</span> <span class="o">=</span> <span class="n">value</span><span class="o">;</span></div><div class='line' id='LC8'>	<span class="o">}</span></div><div class='line' id='LC9'><br/></div><div class='line' id='LC10'>	<span class="kd">public</span> <span class="n">String</span> <span class="nf">getName</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC11'>		<span class="k">return</span> <span class="n">_name</span><span class="o">;</span></div><div class='line' id='LC12'>	<span class="o">}</span></div><div class='line' id='LC13'><br/></div><div class='line' id='LC14'>	<span class="kd">public</span> <span class="n">String</span> <span class="nf">getValue</span><span class="o">()</span> <span class="o">{</span></div><div class='line' id='LC15'>		<span class="k">return</span> <span class="n">_value</span><span class="o">;</span></div><div class='line' id='LC16'>	<span class="o">}</span></div><div class='line' id='LC17'><span class="o">}</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/1324853/03d60e2a639910aa758306712732404e1e27a455/NameValuePair.java" style="float:right;">view raw</a>
            <a href="https://gist.github.com/1324853#file_name_value_pair.java" style="float:right;margin-right:10px;color:#666">NameValuePair.java</a>
            <a href="https://gist.github.com/1324853">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://www.joshdale.net/2011/10/29/restclient-for-blackberry/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

