<?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>Digital Craig</title>
	<atom:link href="http://www.digitalcraig.me/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.digitalcraig.me</link>
	<description>Surviving in the digital wasteland</description>
	<lastBuildDate>Thu, 20 Oct 2011 23:44:34 +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>Be My Valentine (or my first real Android app)</title>
		<link>http://www.digitalcraig.me/2011/02/be-my-valentine-or-my-first-real-android-app/</link>
		<comments>http://www.digitalcraig.me/2011/02/be-my-valentine-or-my-first-real-android-app/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 03:07:10 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Coding]]></category>
		<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/?p=9442</guid>
		<description><![CDATA[It all started with trying to find a way to top the most memorable Valentine&#8217;s Day with my wife. She always talks about the first one after we were married in which I hired a barbershop quartet to serenade her at the front door of our apartment. She claims they sang a song that was a [...]]]></description>
			<content:encoded><![CDATA[<p>It all started with trying to find a way to top the most memorable Valentine&#8217;s Day with my wife. She always talks about the first one after we were married in which I hired a barbershop quartet to serenade her at the front door of our apartment. She claims they sang a song that was a key fixture in our wedding itself, a Victorian song that is also popular with barbershop quartets around Valentine&#8217;s Day. I consider it a lucky break. <img src='http://www.digitalcraig.me/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>I managed to (not so subtly) pry the name of the song from her a few weeks ago and found (what I hope) is an mp3 recording of a barbershop quartet performing it. Of course, I can&#8217;t verify this because I can&#8217;t let her listen to it without tipping my hand. However, even if it&#8217;s not the right one, it&#8217;s at least a romantic song sung by a barbershop quartet with the same name.</p>
<p>So, what to do with it, then? I finally came up with the idea to write an Android app using the song and a few other elements to create a customized Valentine&#8217;s Day greeting card app.</p>
<p><span id="more-9442"></span></p>
<p>The kids got new Nintendo DSi portable gaming devices for Christmas with an app called <a title="Flipnote" href="http://www.nintendodsi.com/flipnotestudio.jsp">Flipnote</a> which allows them to create animations and share them with their friends. This has been the biggest fun for them and I found out that you can export the frames of the animations as individual GIF files to an SD card. It just so happens that Android supports the <a title="AnimationDrawable" href="http://developer.android.com/reference/android/graphics/drawable/AnimationDrawable.html">AnimationDrawable</a> which is defined in XML like so:</p>
<div class="codecolorer-container xml default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="xml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;animation-list</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span><br />
<span style="color: #009900;"> &nbsp;<span style="color: #000066;">android:oneshot</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">android:drawable</span>=<span style="color: #ff0000;">&quot;@drawable/b1001&quot;</span> <span style="color: #000066;">android:duration</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">android:drawable</span>=<span style="color: #ff0000;">&quot;@drawable/b1002&quot;</span> <span style="color: #000066;">android:duration</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">android:drawable</span>=<span style="color: #ff0000;">&quot;@drawable/b1003&quot;</span> <span style="color: #000066;">android:duration</span>=<span style="color: #ff0000;">&quot;200&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; .<br />
&nbsp; &nbsp; .<br />
&nbsp; &nbsp; .<br />
&nbsp; &nbsp;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;item</span> <span style="color: #000066;">android:drawable</span>=<span style="color: #ff0000;">&quot;@drawable/b1068&quot;</span> <span style="color: #000066;">android:duration</span>=<span style="color: #ff0000;">&quot;20000&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/animation-list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div></div>
<p><span style="font-family: monospace;"><br />
</span> The &#8220;@drawable/b1004&#8243; strings will resolve the the individual GIF files in the res/drawables directory in the android package. In this case they are called b1001.gif, b1002.gif, b1003.gif, etc. Also, the animation defined in the XML can be addressed as a @drawable itself and can be controlled in code like so:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">@Override<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onCreate<span style="color: #009900;">&#40;</span>Bundle savedInstanceState<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp;Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Beginning onCreate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Calling super&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onCreate</span><span style="color: #009900;">&#40;</span>savedInstanceState<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp;Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Allocating ImageView animation&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;animationImage <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>ImageView<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">imageView1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;animationImage.<span style="color: #006633;">setBackgroundResource</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">drawable</span>.<span style="color: #006633;">animation</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Animation <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>AnimationDrawable<span style="color: #009900;">&#41;</span> animationImage.<span style="color: #006633;">getBackground</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Allocating AnimationDrawable Animation&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp;Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Ending onCreate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
@Override<br />
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> onTouchEvent<span style="color: #009900;">&#40;</span>MotionEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp;Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Starting onTouchEvent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>event.<span style="color: #006633;">getAction</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> MotionEvent.<span style="color: #006633;">ACTION_DOWN</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">// Start animation</span><br />
&nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Stopping Animation playback using touch event&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; Animation.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Starting Animation playback using touch event&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; Animation.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">true</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Calling Super&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Ending onTouchEvent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onTouchEvent</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<p>The next resource I need is the actual song itself to play. For this, I placed the mp3 file into the res/raw folder and now I can reference it using the generated R class (in this case R.raw.songname in place of res/raw/songname.mp3).</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> playAudio<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Starting playAudio&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Allocating MedaPlayer&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mp <span style="color: #339933;">=</span> MediaPlayer.<span style="color: #006633;">create</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getApplication</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, R.<span style="color: #006633;">raw</span>.<span style="color: #006633;">song</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Starting playback&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mp.<span style="color: #006633;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Ending playAudio&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span></div></div>
<p>The playAudio() function is called anytime in the application lifecycle that the the music should start playing. It&#8217;s important to note here that at this point in the development I started to run into numerous OutOfMemory exceptions and that&#8217;s the reason there are so many calls to Log.d which outputs to the debug console in Eclipse. At first I thought the cause of these was the mediaplayer, but it turned out to be the animation.</p>
<p>The garbage collector cannot reclaim memory unless all references to an object are removed and with a 16MB heap, it looks like all of those GIF images was using up a pretty big chunk. There wasn&#8217;t much room for a reference to be left behind. </p>
<p>As I soon discovered through a lot reading of SDK documentation and forums, the ImageView and the animation itself requires a little bit of extra handling in onPause() and onDestroy(). The ImageView itself retains a reference to the animation resource in it&#8217;s callback and so the callbacks must be set to null and garbage collection initiated:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">void</span> onDestroy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Beginning onDestroy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Calling Super&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onDestroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>mp <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Releasing mediaplayer resource&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mp.<span style="color: #006633;">release</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;mp <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>animationImage <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Release animationImage resource&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; animationImage.<span style="color: #006633;">setBackgroundDrawable</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; animationImage <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Animation <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Stopping and freeing up Animation resource&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Animation.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Animation.<span style="color: #006633;">setCallback</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Animation <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Initiating Garbage Collection&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">gc</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;ending onDestroy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></div>
<p>The final resource I need to manage is an HTML-escaped string displayed in a ScrollView which contains a heartfelt message to the love of my life.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Allocating TextView&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; TextView notes <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>TextView<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">textView1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Getting String Resources&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Resources res <span style="color: #339933;">=</span> getResources<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Formatting note with HTML&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> text <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>res.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">string</span>.<span style="color: #006633;">note</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; CharSequence styledText <span style="color: #339933;">=</span> Html.<span style="color: #006633;">fromHtml</span><span style="color: #009900;">&#40;</span>text<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Assigning formatted text to TextView&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; notes.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span>styledText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>At this point, the application is completely functional. I can install it on a device using a debug key and launch it from the icon in the application manager. I can tap the animation and it plays, the music plays when the application is on-screen, and the text is scrollable. The application also functions in both orientations. However, keep in mind, that I developed the app on my Motorola Droid X for my wife&#8217;s Motorola Droid and the app is not for general release so I probably made a lot of assumptions about device capabilities.</p>
<p>There is one final feature that I really wanted to add to make it fully functional. At a given date and time (February 14, 2011 7:00am), I wanted a notification to appear with a heart icon and the text &#8220;Be My Valentine&#8221;. When she sees that and selects the notification, I want the app to start and do its thing. When the day is over, I want the notification to no longer show up. As it turns out, implementing this one feature was nearly as much work as all the entire app itself.</p>
<p>There are several pieces to this: an alarm, a service, a receiver, and a binder.</p>
<p>First in the UI class&#8217;s onCreate(), I need to start the service I created to handle notifications using an alarm at a particular time:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Create an IntentSender that will launch our service, to be scheduled</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// with the alarm manager.</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Creating AlarmSender&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mAlarmSender <span style="color: #339933;">=</span> PendingIntent.<span style="color: #006633;">getService</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span>BeMyValentine.<span style="color: #000000; font-weight: bold;">this</span>, BeMyValentineService.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Setting time for alarm&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a> calendar <span style="color: #339933;">=</span> &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agregoriancalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">GregorianCalendar</span></a>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; calendar.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">YEAR</span>,<span style="color: #cc66cc;">2011</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; calendar.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">MONTH</span>,<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">FEBRUARY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; calendar.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">DAY_OF_MONTH</span>,<span style="color: #cc66cc;">14</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; calendar.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">HOUR_OF_DAY</span>,<span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; calendar.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">MINUTE</span>,00<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,calendar.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Schedule the alarm!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Scheduling alarm&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Schedule the alarm!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; AlarmManager am <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>AlarmManager<span style="color: #009900;">&#41;</span>getSystemService<span style="color: #009900;">&#40;</span>ALARM_SERVICE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; am.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span>AlarmManager.<span style="color: #006633;">RTC_WAKEUP</span>, calendar.<span style="color: #006633;">getTimeInMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, mAlarmSender<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></div>
<p>I also need a broadcast receiver to handle broadcasts sent to my application. Specifically, the broadcast generated by the alarm which will start the service.</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> BeMyValentineReceiver <span style="color: #000000; font-weight: bold;">extends</span> BroadcastReceiver <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> TAG <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;BeMyValentine&quot;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onReceive<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acontext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Context</span></a> context, Intent intent<span style="color: #009900;">&#41;</span> &nbsp;<span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Receiver: starting onReceive&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// we start notification service on start up</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Receiver: creating intent for service&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Intent startActivityIntent <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span>context, BeMyValentineService.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Receiver: starting service&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; context.<span style="color: #006633;">startService</span><span style="color: #009900;">&#40;</span>startActivityIntent <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Receiver: ending onReceive&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #009900;">&#125;</span></div></div>
<p>Now for the real workhorse of this feature, the BeMyValentineService. In the service&#8217;s onCreate(), I call a function to display the notification by creating an intent to launch the app and calling the system notification service to display it (this will quickly disappear if the date not February 14, 2011):</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* Show a notification while this service is running.<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> showNotification<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Set up Notification</span><br />
&nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Service: Creating intent&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Intent intent <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Intent<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>,BeMyValentine.<span style="color: #000000; font-weight: bold;">class</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mManager <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>NotificationManager<span style="color: #009900;">&#41;</span> getSystemService<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acontext+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Context</span></a>.<span style="color: #006633;">NOTIFICATION_SERVICE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp;&nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Service: Creating notification&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Notification notification <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Notification<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">drawable</span>.<span style="color: #006633;">icon</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;Notify&quot;</span>, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; notification.<span style="color: #006633;">setLatestEventInfo</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">&quot;Be My Valentine&quot;</span>,<span style="color: #0000ff;">&quot;Select for a special message&quot;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PendingIntent.<span style="color: #006633;">getActivity</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getBaseContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">0</span>, intent,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PendingIntent.<span style="color: #006633;">FLAG_CANCEL_CURRENT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Service: Sending notification notification to manager&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mManager.<span style="color: #006633;">notify</span><span style="color: #009900;">&#40;</span>APP_ID, notification<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Service: ending onCreate&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #009900;">&#125;</span></div></div>
<p>Next, I create and start a thread whose job it is to wait until a specific time and tell the service to shut itself down:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #008000; font-style: italic; font-weight: bold;">/**<br />
&nbsp; &nbsp; &nbsp;* The function that runs in our worker thread<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Arunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Runnable</span></a> mTask <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Arunnable+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Runnable</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> run<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Setting time for alarm&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a> cal <span style="color: #339933;">=</span> &nbsp;<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Agregoriancalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">GregorianCalendar</span></a>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cal.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">YEAR</span>,<span style="color: #cc66cc;">2011</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cal.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">MONTH</span>,<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">FEBRUARY</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cal.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">DAY_OF_MONTH</span>,<span style="color: #cc66cc;">14</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cal.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">HOUR_OF_DAY</span>,<span style="color: #cc66cc;">23</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cal.<span style="color: #006633;">set</span><span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Acalendar+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Calendar</span></a>.<span style="color: #006633;">MINUTE</span>,<span style="color: #cc66cc;">59</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,cal.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">long</span> endTime <span style="color: #339933;">=</span> cal.<span style="color: #006633;">getTimeInMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> endTime<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">synchronized</span> <span style="color: #009900;">&#40;</span>mBinder<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mBinder.<span style="color: #006633;">wait</span><span style="color: #009900;">&#40;</span>endTime <span style="color: #339933;">-</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Done with our work... &nbsp;stop the service!</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BeMyValentineService.<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">stopSelf</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p>Of course, part of the service shutting down is to cancel the notification:</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onDestroy<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Service: starting onDestroy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; mManager.<span style="color: #006633;">cancel</span><span style="color: #009900;">&#40;</span>APP_ID<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,<span style="color: #0000ff;">&quot;Service: calling Super&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onDestroy</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG, <span style="color: #0000ff;">&quot;Service: ending onDestroy&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></div>
<p>Finally, the glue that holds it all together is the binder object which synchronizes the work of the thread (it&#8217;s returned in the service&#8217;s onBind() function).</p>
<div class="codecolorer-container java default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> IBinder mBinder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Binder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; @Override<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000066; font-weight: bold;">boolean</span> onTransact<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> code, Parcel data, Parcel reply,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">int</span> flags<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aremoteexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">RemoteException</span></a> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">onTransact</span><span style="color: #009900;">&#40;</span>code, data, reply, flags<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></div>
<p>One final note. I&#8217;ve only posted sections of code use to highlight particular challenges I had to solve. There are a lot of smaller pieces that are used to put it all together and I relied heavily on the SDK documentation, the SDK sample code, <a href="http://www.stackoverflow.com">StackOverflow</a>, and other forums.</p>
<p>Feel free to contact me if you want more information or help with solving a similar problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2011/02/be-my-valentine-or-my-first-real-android-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Insulin for me</title>
		<link>http://www.digitalcraig.me/2010/12/insulin-for-me/</link>
		<comments>http://www.digitalcraig.me/2010/12/insulin-for-me/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 20:59:04 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Diabetes]]></category>
		<category><![CDATA[Medical]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/?p=8323</guid>
		<description><![CDATA[Here it is December 20th, just before Christmas and two weeks into my journaling project. Although the volume of my daily entries has gone down significantly, I am still doing it. I&#8217;m sticking to major events and just capturing the highlights. It&#8217;s not exactly what I set out to do, but I&#8217;m pleased that I [...]]]></description>
			<content:encoded><![CDATA[<p>Here it is December 20th, just before Christmas and two weeks into my journaling project. Although the volume of my daily entries has gone down significantly, I am still doing it. I&#8217;m sticking to major events and just capturing the highlights. It&#8217;s not exactly what I set out to do, but I&#8217;m pleased that I am still doing it at all since I grossly underestimated the time  and effort it takes to be so detailed.</p>
<p>The big news for this week is that I had another visit with the doctor. He mentioned once before in passing that it might be a good idea to try a basal insulin routine as a way to help bring the blood sugar down overnight. It&#8217;s also mentioned on the Bloodsugar 101 site that insulin shouldn&#8217;t be viewed as a last resort or the &#8220;we lost the fight&#8221; option, but it is the body&#8217;s natural way to utilize glucose and should be used to help relieve the body rather than medications with severe side-effects (especially fatal ones).</p>
<p>So, I led the appointment with the idea of trying insulin since my a1c results were back up and since the last time he increased my medication dosage, it seemed like I was always on verge of going hypo every afternoon unless I ate extra carbs which was not the right thing to do. In fact, I wasn&#8217;t going hypo, but the wild fluctuations in my blood  glucose levels left me feeling that way. He agreed to the idea and put me on 10 units of basal insulin at bedtime as well as drastically reduce the medication which stimulates the production of insulin.</p>
<p>It&#8217;s been 4 days and my fasting sugars are down and seem to be more stable throughout the day. They are still high and I believe he&#8217;ll have to increase the dosage, but I do feel much better. I&#8217;ve even renewed my commitment to the low-carb lifestyle.</p>
<p>Since my new job means I have a commute that is over an hour, I&#8217;ve been going to the gym at the office in order to allow traffic to ease up so I can spend as little time in the car. This has worked okay, but I&#8217;m working from home this week and will be working from home more often as I come up to speed in my duties. As a result, I&#8217;ve signed up a membership with <a href="http://www.lafitness.com">LA Fitness</a>. There is one both near where I live and one just down the street from the office so I&#8217;ll have one membership and two locations available to me. It should help to have some consistency in routine and available equipment.</p>
<p>I came across <a href="http://www.latimes.com/health/la-he-carbs-20101220,0,5464425.story">this article</a> yesterday which was really satisfying to read since there is so much power behind the false message of low-fat diets. Dr. Atkins discovered the principles in the article and first wrote about them in the 1970s. I&#8217;m becoming more and more convinced that the world&#8217;s obesity problems can directly be attributed to high-carb, low-fat diets and especially to high-fructose corn syrup (now renamed corn sugar). My favorite quote from the article is:</p>
<blockquote><p>Carbohydrates are a metabolic bully,&#8221; Phinney says. &#8220;They cut in front of fat as a fuel source and insist on being burned first. What isn&#8217;t burned gets stored as fat, and doesn&#8217;t come out of storage as long as carbs are available. And in the average American diet, they always are.&#8221;</p></blockquote>
<p>Particularly if you have a history of diabetes in your family, as I do, you need to read the article and listen to its message. I had many opportunities to listen  and I wish now I had done more about it. I read Dr. Atkins book and had lost over 50 lbs on the diet several years before I gave up the low-carb lifestyle and ended up with Diabetes.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/12/insulin-for-me/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Journaling Project</title>
		<link>http://www.digitalcraig.me/2010/12/journaling-project/</link>
		<comments>http://www.digitalcraig.me/2010/12/journaling-project/#comments</comments>
		<pubDate>Thu, 09 Dec 2010 04:16:01 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Musings]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/?p=8168</guid>
		<description><![CDATA[I&#8217;ve started a new experimental journaling project using Evernote. The aim isn&#8217;t necessarily to help with blogging, but I suspect that will be a side-effect. I&#8217;ve tried several different ways of doing journaling and I always allow it to be a Big Deal &#8482;. I allow myself to become obsessed with *what* I&#8217;m going to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started a new experimental journaling project using <a href="http://www.evernote.com">Evernote</a>. The aim isn&#8217;t necessarily to help with blogging, but I suspect that will be a side-effect. I&#8217;ve tried several different ways of doing journaling and I always allow it to be a Big Deal &#8482;. I allow myself to become obsessed with *what* I&#8217;m going to post, *how* it will sound, *what* the audience is, etc to the point that I never post anything.</p>
<p>This new project is essentially to keep a detailed (how detailed is still to be determined) private journal of my activities throughout the day without any expectation that it will ever become anything more than a list of things I did that day. My thinking with this is that if I spend all of my retentive energy with the initial-list making that I&#8217;ll be freer to take that information and actually do something with it. I can train myself to not filter the input, but filter the output so to speak.</p>
<p>The corollary to this project is that I&#8217;m consider trying  to write a weekly blog post summarizing the week in some way, most likely an actual narrative. This will be the public part of the journal that, when combined with the private part of the journal, tells the whole story. Depending whether you want the complete picture with all of the mundane details or just the reader&#8217;s digest version. If nothing else, it will be something I can share with my posterity.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/12/journaling-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Minecraft</title>
		<link>http://www.digitalcraig.me/2010/08/minecraft/</link>
		<comments>http://www.digitalcraig.me/2010/08/minecraft/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 03:12:31 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[gaming]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/?p=4352</guid>
		<description><![CDATA[I discovered Minecraft a few weeks ago. I immediately bought two copies -- one for me and one for my son so we could play multiplayer together. It was recently picked up by the guys at machinima.com and the videos are getting a lot of attention on youtube. The author is saying he&#8217;s getting 2500-4000 [...]]]></description>
			<content:encoded><![CDATA[<p>I discovered <a href="http://www.minecraft.net">Minecraft</a> a few weeks ago. I immediately bought two copies -- one for me and one for my son so we could play multiplayer together. It was recently picked up by the guys at machinima.com and the videos are getting a lot of attention on youtube. The author is saying he&#8217;s getting 2500-4000 sales <i>per day</i>. Actually, these are pre-orders for the full game which gets you access to alpha.</p>
<p>The original game, now called classic, was a basic block-building sandbox game which has been around for about a year. You had unlimited resources, so other than building cool stuff, there wasn&#8217;t much to do. This version is still available and it&#8217;s free to play. The fun, however, is in the alpha version which costs 10 euros.</p>
<p>The entire world is randomly generated of blocks of different textures: stone, dirt, sand, gold ore, coal, water, lava, etc. Your job is to gather resources, craft tools, an explore. However, the bad guys comes out and night and try to kill you so it&#8217;s a challenge just to survive.</p>
<p>Here&#8217;s an intro video..</p>
<p><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/ylVtj-1Ccgg?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;modestbranding=1&amp;loop=&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&#038;feature=player_embedded" />
<param name="allowFullScreen" value="true" />
<embed wmode="opaque" src="http://www.youtube.com/v/ylVtj-1Ccgg?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;modestbranding=1&amp;loop=&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&#038;feature=player_embedded" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="355"></embed>
<param name="wmode" value="opaque" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=ylVtj-1Ccgg">www.youtube.com/watch?v=ylVtj-1Ccgg</a></p></p>
<p>Here&#8217;s another video that shows some off some of the cool stuff you can build..</p>
<p><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/krZgXzSAbkA?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;modestbranding=1&amp;loop=&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&#038;feature=player_embedded" />
<param name="allowFullScreen" value="true" />
<embed wmode="opaque" src="http://www.youtube.com/v/krZgXzSAbkA?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;modestbranding=1&amp;loop=&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1&#038;feature=player_embedded" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="355"></embed>
<param name="wmode" value="opaque" />
</object>
</span><p><a href="http://www.youtube.com/watch?v=krZgXzSAbkA">www.youtube.com/watch?v=krZgXzSAbkA</a></p></p>
<p>This is such a fun game and there are so many neat things to discover and do. I highly recommend reading the <a href="http://www.minecraftwiki.net">wiki</a>for more ideas.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/08/minecraft/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Email Apnea?</title>
		<link>http://www.digitalcraig.me/2010/07/email-apnea/</link>
		<comments>http://www.digitalcraig.me/2010/07/email-apnea/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 13:02:37 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Medical]]></category>
		<category><![CDATA[Odd Stuff]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/2010/07/email-apnea/</guid>
		<description><![CDATA[Diagnosis: Email Apnea? I&#8217;ve just opened my email and there&#8217;s nothing out of the ordinary there. It&#8217;s the usual daily flood of schedule, project, travel, information, and junk mail. Then I notice. I&#8217;m holding my breath. As the email spills onto my screen, as my mind races with thoughts of what I&#8217;ll answer first, what [...]]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">
<div class="posterous_bookmarklet_entry">
<blockquote>
<div>
<h3><a href="http://radar.oreilly.com/2008/02/diagnosis-email-apnea.html" target="_self">Diagnosis:  Email Apnea?</a></h3>
<p>I&#8217;ve just opened my email and there&#8217;s nothing out of the ordinary there.  It&#8217;s the usual daily flood of schedule, project, travel, information, and junk mail.  Then I notice.  I&#8217;m holding my breath.  <img src="http://guterman.com/stone.jpg" border="0&quot;" alt="apnea illo" width="166" height="248" align="right" /></p>
<p>As the email spills onto my screen, as my mind races with thoughts of what I&#8217;ll answer first, what can wait, who I should call, what should have been done two days ago; I&#8217;ve stopped the steady breathing I was doing only moments earlier in a morning meditation and now, I&#8217;m holding my breath.</p>
<p>And here&#8217;s the deal: You&#8217;re probably holding your breath, too.</p>
<p>I wanted to know &#8212; how widespread is <em>email apnea</em>*?  I observed others on computers and BlackBerries:  in their offices, their homes, at cafes. The vast majority of people held their breath, or breathed very shallowly, especially when responding to email. I watched people on cell phones, talking and walking, and noticed that most were mouth-breathing and hyperventilating.   Consider also, that for many, posture while seated at a computer can contribute to restricted breathing.</p>
<p>Does it matter?  How was holding my breath affecting me?</p>
</div>
</blockquote>
<div class="posterous_quote_citation">via <a href="http://radar.oreilly.com/archives/2008/02/diagnosis-email-apnea.html">radar.oreilly.com</a></div>
<p>The article is a few years old, but I just heard about this the other day. As a person with Obstructive Sleep Apnea (OSA), I can relate to this. I have also noticed the phenomena when I&#8217;m intently reading or writing an important e-mail (or blog post).</p>
<p>What I found most interesting is that there are tools to help with this. One is an O2 sensor that you clip to your ear and when your oxygen saturation dips below a certain level, a red dot to will show up on your monitor to remind you to breathe.</p>
<p>Yes, REMIND you to breathe. Sounds funny to say, but it&#8217;s apparently a growing problem.</p>
</div>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via email</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/07/email-apnea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Pledge of Allegiance</title>
		<link>http://www.digitalcraig.me/2010/06/the-pledge-of-allegiance/</link>
		<comments>http://www.digitalcraig.me/2010/06/the-pledge-of-allegiance/#comments</comments>
		<pubDate>Thu, 10 Jun 2010 03:37:13 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Musings]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/2010/06/the-pledge-of-allegiance/</guid>
		<description><![CDATA[via youtube.com Posted via web]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">
<div class="posterous_bookmarklet_entry"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="417" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="wmode" value="window" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/TZBTyTWOZCM&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="500" height="417" src="http://www.youtube.com/v/TZBTyTWOZCM&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true" wmode="window"></embed></object></p>
<div class="posterous_quote_citation">via <a href="http://www.youtube.com/watch?v=TZBTyTWOZCM&amp;feature=youtu.be">youtube.com</a></div>
</div>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via web</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/06/the-pledge-of-allegiance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Man&#8217;s Game</title>
		<link>http://www.digitalcraig.me/2010/05/mans-game/</link>
		<comments>http://www.digitalcraig.me/2010/05/mans-game/#comments</comments>
		<pubDate>Sat, 22 May 2010 11:48:30 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Humor]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/2010/05/mans-game/</guid>
		<description><![CDATA[via youtube.com EYE HAV ATHMAH! Posted via web]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">
<div class="posterous_bookmarklet_entry"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="wmode" value="window" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/JhmYMdel2mc&amp;hl=en&amp;fs=1&amp;hd=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="500" height="300" src="http://www.youtube.com/v/JhmYMdel2mc&amp;hl=en&amp;fs=1&amp;hd=1" allowscriptaccess="always" allowfullscreen="true" wmode="window"></embed></object></p>
<div class="posterous_quote_citation">via <a href="http://www.youtube.com/watch?v=JhmYMdel2mc&amp;feature=fvw">youtube.com</a></div>
<p>EYE HAV ATHMAH!</p>
</div>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via web</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/05/mans-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic Lawn Mower</title>
		<link>http://www.digitalcraig.me/2010/04/automatic-lawn-mower/</link>
		<comments>http://www.digitalcraig.me/2010/04/automatic-lawn-mower/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 12:10:17 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/2010/04/automatic-lawn-mower/</guid>
		<description><![CDATA[via thereifixedit.com Where do I get one of these?! Posted via web]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">
<div class="posterous_bookmarklet_entry"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="412" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowScriptAccess" value="always" /><param name="wmode" value="opaque" /><param name="src" value="http://www.viddler.com/player/8e41449e" /><param name="name" value="viddler" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="500" height="412" src="http://www.viddler.com/player/8e41449e" allowfullscreen="true" name="viddler" wmode="opaque" allowscriptaccess="always"></embed></object></p>
<div class="posterous_quote_citation">via <a href="http://thereifixedit.com/2010/04/23/epic-kludge-photo-automatic-lawn-mower/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+ThereIFixedIt+%28There%2C+I+Fixed+It.%29&amp;utm_content=Google+Reader">thereifixedit.com</a></div>
<p>Where do I get one of these?!</p>
</div>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via web</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/04/automatic-lawn-mower/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10/GUI &#8211; 10 Finger Multitouch User Interface</title>
		<link>http://www.digitalcraig.me/2010/04/10gui-10-finger-multitouch-user-interface/</link>
		<comments>http://www.digitalcraig.me/2010/04/10gui-10-finger-multitouch-user-interface/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 16:38:46 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Future Tech]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/2010/04/10gui-10-finger-multitouch-user-interface/</guid>
		<description><![CDATA[via youtube.com Speaking of the future. I want this interface. Posted via web]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">
<div class="posterous_bookmarklet_entry"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="417" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="wmode" value="window" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/zWz1KbknIZk&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="500" height="417" src="http://www.youtube.com/v/zWz1KbknIZk&amp;hl=en&amp;fs=1" allowscriptaccess="always" allowfullscreen="true" wmode="window"></embed></object></p>
<div class="posterous_quote_citation">via <a href="http://www.youtube.com/watch?v=zWz1KbknIZk">youtube.com</a></div>
<p>Speaking of the future. I <em>want</em> this interface.</p>
</div>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via web</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/04/10gui-10-finger-multitouch-user-interface/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Living in the future</title>
		<link>http://www.digitalcraig.me/2010/04/living-in-the-future/</link>
		<comments>http://www.digitalcraig.me/2010/04/living-in-the-future/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 16:14:41 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[Musings]]></category>

		<guid isPermaLink="false">http://www.digitalcraig.me/2010/04/living-in-the-future/</guid>
		<description><![CDATA[I know it hasn’t occurred to me alone, partly because I have seen the idea expressed by others before, but I think we often overlook the wonderful fact that we live in the future. Remember those old films about the promises of the next century? Well, I look around in the distant future of Twenty-Ten [...]]]></description>
			<content:encoded><![CDATA[<div class="posterous_autopost">
<div class="posterous_bookmarklet_entry">
<blockquote>
<div><img src="http://posterous.com/getfile/files.posterous.com/digitalcraig/qAafCuwxqGAhnCGicpGbkdoxnxBcxCEqFgIgdDbknrxuEqCmbhbFxtpttGCz/media_httpblogkindlec_wDEsC.gif.scaled500.gif" alt="" width="220" height="239" /></p>
<div class="posterous_quote_citation">
<p>I know it hasn’t occurred to me alone, partly because I have seen the idea expressed by others before, but I think we often overlook the wonderful fact that we live in the future.  Remember those old films about the promises of the next century?  Well, I look around in the distant future of Twenty-Ten and realize that we got a few of them right.</p>
<p>Sure, we don’t have flying cars.  I could care less about that.  The first time my gas light came on in the middle of nowhere, I’m pretty sure I’d swear off them permanently anyway.  What we do have is the <a rel="nofollow" href="http://www.amazon.com/gp/product/B0015T963C?ie=UTF8&amp;tag=blogkindle0e-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B0015T963C">Kindle</a>.  Think about it.</p>
<p>Every day, I can wake up and have the newspaper already sitting on my desk in the form of a piece of “paper” that changes on a daily basis or whenever I happen to need it for something.  I carry around the better part of a library in my pocket, and when I find I’m lacking something it’s the matter of a few moments while it is beamed to me from far off locales to prevent me the inconvenience of getting up and driving to the store.  In moments of curiosity, this wonderful device can get me answers to most any question by accessing one of the largest knowledge bases in existence from nearly anywhere in the world at no charge with no questions asked.</p>
<p>It’s so mundane right now, too.  That’s quite possibly the most surreal point of all.  We have devices like the <a rel="nofollow" href="http://www.amazon.com/gp/product/B0015T963C?ie=UTF8&amp;tag=blogkindle0e-20&amp;linkCode=as2&amp;camp=1789&amp;creative=9325&amp;creativeASIN=B0015T963C">Kindle</a> and nook and a dozen others to choose from, the main difference between them often being aesthetics and level of convenience, and nobody even realizes what they mean!</p>
<p>I’m still holding out for an affordable version of the house that wakes me up and cooks me breakfast every morning, but I’m willing to let that one slide.  So long as I can sit here with an eReader and enjoy, the future is good.</p>
</div>
</div>
</blockquote>
<div class="posterous_quote_citation">via <a href="http://blogkindle.com/2010/04/living-in-the-future/?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+BlogKindle+%28Blog+Kindle%3A+The+Amazon+Kindle+Blog%29&amp;utm_content=Google+Reader">blogkindle.com</a></div>
<p>When you think about it, what does all of the talk about Kindle vs. iPad really matter, anyway? The future I dreamed of 10 years ago is here now.</p>
<p>I have universal access to the content I care about when I&#8217;m on the go. I have my choice of form factors and navigation features between the various Kindle apps and the Kindle itself. When you add things like Calibre, Instapaper, and Scribd into the mix you&#8217;ve got the makings of a very tasty concoction indeed.</p>
<p>I embraced the Steve Jobs way of doing things for a long time and I do long for an iPad at some level. However, I&#8217;ve come to realize that Apple will always dictate how and what you can do with their devices and that elitist attitude is something I&#8217;ve come to loathe.</p>
</div>
<p style="font-size: 10px;"><a href="http://posterous.com">Posted via web</a></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.digitalcraig.me/2010/04/living-in-the-future/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

