<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>Active Frequency</title>
	
	<link>http://activefrequency.com/blog</link>
	<description>Web Development and Design</description>
	<lastBuildDate>Fri, 23 Oct 2009 18:18:39 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/activefrequencyblog" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="activefrequencyblog" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Ground-Up Android, Part 5: Tweeting and Debugging</title>
		<link>http://activefrequency.com/blog/2009/ground-up-android-part-5-tweeting-and-debugging/</link>
		<comments>http://activefrequency.com/blog/2009/ground-up-android-part-5-tweeting-and-debugging/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:41:52 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[twitternator-tutorial]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=279</guid>
		<description><![CDATA[This is part 5 of a 5-part series on introductory Android development. If you&#8217;re just arriving, you should head on over to Part 1.
In Part 4, we dug into accessing our Views from our Activity&#8217;s code, and registered an OnClickListener to handle the user&#8217;s interactions with our button. In the final part (a big one!) [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is part 5 of a <a href="http://activefrequency.com/blog/tag/twitternator-tutorial/">5-part series</a> on introductory Android development. If you&#8217;re just arriving, you should head on over to <a href="http://activefrequency.com/blog/2009/ground-up-android-getting-started-with-app-development">Part 1</a>.</em></p>
<p>In <a href="http://activefrequency.com/blog/2009/ground-up-android-part-4-writing-the-code/">Part 4</a>, we dug into accessing our Views from our Activity&#8217;s code, and registered an OnClickListener to handle the user&#8217;s interactions with our button. In the final part (a big one!) we&#8217;ll cover using J2SE libraries, debugging, and Android permissions.</p>
<p>So far we&#8217;ve gotten a lot done without too much &#8220;boilerplate&#8221; coding, and that&#8217;s great. But what we don&#8217;t have (yet) is an application that leaves its mark on the world. After all, what&#8217;s a Twitter application if people can&#8217;t benefit from your 140 characters of deep, meaningful insight into the state of the world (or what you ate for breakfast)?</p>
<p><span id="more-279"></span></p>
<h2>On the shoulders of giants</h2>
<p>One great thing about Android is that you have access to a full J2SE stack. That means you can take advantage of lots of libraries other <span style="text-decoration: line-through;">suckers</span> wonderfully generous people have already written. There are some caveats &#8212; code using some kinds of runtime code modification / introspection or deep JVM voodoo won&#8217;t work properly under Dalvik, for example &#8212; but many simpler libraries can be partially reused or just dropped in wholesale in JAR form. For twitter, there&#8217;s a great super-light library called <a href="http://www.winterwell.com/software/jtwitter.php" target="_blank">JTwitter</a>, released with an LGPL license. Go ahead and download that now &#8212; I&#8217;ll wait.</p>
<p>Done? Great! Put the .jar file into your project. I&#8217;ll create a /lib folder in our project and drag the file there, but you could also keep it in a totally separate folder on your computer to be linked as an external .jar in the project. Then go to Project -&gt; Properties and add the .jar file (add as an external if you&#8217;re keeping the .jar outside your project&#8217;s folder). And that&#8217;s it &#8212; Android&#8217;s SDK tools take care of turning the compiled code in the .JAR file into proper Android Dalvik bytecode behind the scenes.</p>
<p>Now let&#8217;s wire that Twitter code in.</p>
<p>Add at the top of the Activity class:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> TWITTER_USERNAME <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;someusername&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">String</span> TWITTER_PASSWORD <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;somepassword&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//this is a very bad idea for a real product.</span></pre></td></tr></table></div>

<p>And add to our onclick handler right before popping up that Toast:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">Twitter twitter <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Twitter<span style="color: #009900;">&#40;</span>TWITTER_USERNAME, TWITTER_PASSWORD<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
twitter.<span style="color: #006633;">updateStatus</span><span style="color: #009900;">&#40;</span>twitterStatus<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>(Again, you&#8217;ll get easily-corrected missing-import errors &#8211; let Eclipse autofix that for you by importing winterwell.jtwitter.Twitter).</p>
<h2>Advance warnings</h2>
<p>Cool &#8211; before we run it, though, here&#8217;s 3 big caveats/notes:</p>
<ol>
<li>For the purposes of this demo, I&#8217;m hardcoding a password into my file. Don&#8217;t do this. You probably want to use OAuth, or at least prompt the user for their password and store the encrypted version somewhere.</li>
<li>This is running in the same thread as your UI. This makes your app hang during the operation, and could lead to the user being prompted to end your app for being unresponsive (the dreaded &#8220;ANR&#8221; dialog). For a real app, you&#8217;d run the twitter-posting in a separate thread or as a background service, but that&#8217;s outside the scope of this tutorial.</li>
<li>This actually won&#8217;t work yet &#8211; trust me, I&#8217;m showing you how to debug things. Pretend to be surprised, though.</li>
</ol>
<p>Go ahead and run the app in debug mode in the emulator (run -&gt; debug -&gt; Android Application). When it loads up, type in a message and click the Tweet! button.</p>
<div id="attachment_281" class="wp-caption alignnone" style="width: 214px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/emulator-before-debug.png"><img src="http://media.activefrequency.com/wp-uploads/2009/10/emulator-before-debug-204x300.png" alt="Click &#039;Tweet!&#039;, and then..." title="emulator-before-debug" width="204" height="300" class="size-medium wp-image-281" /></a><p class="wp-caption-text">Click 'Tweet!', and then...</p></div>
<p>You&#8217;ll find yourself rudely thrown back into Eclipse with this error message:</p>
<div id="attachment_282" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/Confirm-Perspective-Switch.png"><img src="http://media.activefrequency.com/wp-uploads/2009/10/Confirm-Perspective-Switch-300x152.png" alt="Oh no!" title="Confirm Perspective Switch" width="300" height="152" class="size-medium wp-image-282" /></a><p class="wp-caption-text">Oh no!</p></div>
<h2>When things go wrong</h2>
<p>Whoops! So your code isn&#8217;t doing what you expect &#8212; and worse yet, it blows up and crashes &#8211; hard. Once upon a time you&#8217;d have to know a series of arcane serial debugging commands to get anything resembling useful output from a mobile phone application. But thanks to the magic of DDMS (Dalvik Debug Monitoring Service), debugging your code is as minimally painful as anything I&#8217;ve used until now, and is *actually* less painful than a root canal! Let&#8217;s step through the Perspective you get thrown into in Eclipse.</p>
<div id="attachment_284" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/debug-view.png"><img src="http://media.activefrequency.com/wp-uploads/2009/10/debug-view-300x193.png" alt="The debug perspective" title="debug-view" width="300" height="193" class="size-medium wp-image-284" /></a><p class="wp-caption-text">The debug perspective</p></div>
<p>You&#8217;ll notice you can use the Debug panel to view the current state of our application as well as any variables. You can also see the Logcat error messages, which are generated by various application and system events (you can create your own using the <a href="http://developer.android.com/reference/android/util/Log.html" target="_blank">android.util.Log</a> library). Right now the only relevant log entry says &#8220;InetAddr Unknown host twitter.com,&#8221; which isn&#8217;t really helpful, but the execution has been paused to let us inspect the code behind that top-level error.</p>
<p>We can resume execution through the exception to the next line of code causing it. Usually this can get you a more detailed error message, and you can even inspect the code and variables at each step. Try it now (it&#8217;s the button that looks like &#8220;Play&#8221; on a tape deck &#8212; yes, I said tape deck; so I&#8217;m dating myself a bit), and notice the log messages scrolling at the bottom (you might have to click Resume a few times to get the right level of detail).</p>
<div id="attachment_289" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/logcat-error1.png"><img src="http://media.activefrequency.com/wp-uploads/2009/10/logcat-error1-300x76.png" alt="That&#039;s much more helpful." title="logcat-error" width="300" height="76" class="size-medium wp-image-289" /></a><p class="wp-caption-text">That's much more helpful.</p></div>
<p>You can use the Logcat view&#8217;s controls to filter error messages by severity or tag if there&#8217;s a lot to sort through &#8212; in this case, though, a little reading makes the culprit fairly obvious. We never told the app that it needs to ask for Internet access permissions!</p>
<p>Let&#8217;s go back and add that to AndroidManifest.xml. Again, you can use the XML wizardy-view to go to the Permissions section and add Uses Permissions -&gt; android.permission.INTERNET, but if you&#8217;re old-school or just prefer a good text edit, add this line to the &lt;manifest&gt; node (usually as the last thing before &lt;/manifest&gt;):</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses-permission</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.permission.INTERNET&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/uses-permission<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Now when your users install this app, they&#8217;re warned once on installation that your application will access the Internet (but never again after that).</p>
<p>Go ahead and run one more time, filling in a message:</p>
<div id="attachment_291" class="wp-caption alignnone" style="width: 214px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/emulator-toast1.png"><img src="http://media.activefrequency.com/wp-uploads/2009/10/emulator-toast1-204x300.png" alt="Now with 100% fewer Exceptions!" title="emulator-toast" width="204" height="300" class="size-medium wp-image-291" /></a><p class="wp-caption-text">Now with 100% fewer Exceptions!</p></div>
<p>And check out our test Twitter account:</p>
<div id="attachment_292" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/twitter-posted.png"><img src="http://media.activefrequency.com/wp-uploads/2009/10/twitter-posted-300x105.png" alt="It worked!" title="twitter-posted" width="300" height="105" class="size-medium wp-image-292" /></a><p class="wp-caption-text">It worked!</p></div>
<p>Hooray!</p>
<p>This concludes the tutorial &#8211; but hopefully just starts your Android development experience. Go ahead, start making an app of your own!</p>
<p>To get started (or in case you got lost during this tutorial) you can <a href="http://static.activefrequency.com/fitc/twitter-intro-code.zip">download the source</a> of the application we&#8217;ve built. You can also comment away if you have any questions or feedback on the tutorial.</p>
<p>If you just want to bang around with some more advanced development techniques without starting from scratch, here are some ways you could improve the current app:</p>
<ul>
<li>Use the AsyncTask class or a Service to make the updating happen in the background instead of locking the UI</li>
<li>prompt the user for a username/password on first use, using a Preferences activity (easy way: Preferences from XML)</li>
<li>Handle network failure gracefully.</li>
<li>Display a progress bar / loading spinner while tweeting.</li>
<li>Display updates from the users&#8217; timeline in a ListView.</li>
<li>use an AlarmService to update the Timeline in the background, displaying a notification to the user</li>
<li>Cache tweets to an SQLite database or a flat file on the SD card</li>
<li>Use the Location services and the reverse-geocoder classes to tweet your location</li>
</ul>
<p>I&#8217;ll also be posting a more advanced tutorial on AppWidgets (homescreen widgets) soon &#8211; so subscribe to the Active Frequency blog in your RSS reader.</p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/ground-up-android-part-5-tweeting-and-debugging/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Ground-Up Android, Part 4: Writing the Code</title>
		<link>http://activefrequency.com/blog/2009/ground-up-android-part-4-writing-the-code/</link>
		<comments>http://activefrequency.com/blog/2009/ground-up-android-part-4-writing-the-code/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:28:57 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[twitternator-tutorial]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=275</guid>
		<description><![CDATA[This is part 4 of a 5-part series on introductory Android development. If you&#8217;re just arriving, you should head on over to Part 1.
In Part 3, we defined our layout and prettied up our app&#8217;s main screen. Now let&#8217;s get to the business of real coding &#8211; the stuff that makes the app tick behind [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is part 4 of a <a href="http://activefrequency.com/blog/tag/twitternator-tutorial/">5-part series</a> on introductory Android development. If you&#8217;re just arriving, you should head on over to <a href="http://activefrequency.com/blog/2009/ground-up-android-getting-started-with-app-development">Part 1</a>.</em></p>
<p>In <a href="http://activefrequency.com/blog/2009/ground-up-android-part-3-describing-your-layout/">Part 3</a>, we defined our layout and prettied up our app&#8217;s main screen. Now let&#8217;s get to the business of real coding &#8211; the stuff that makes the app tick behind the scenes.</p>
<p><span id="more-275"></span></p>
<h2>The Activity</h2>
<p>So far, there&#8217;s only a few pre-created lines in our Activity, TwitterPoster.java:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><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>
    <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>
    setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Let&#8217;s break that down a bit. What this is saying is:<br />
When our Activity is created,<br />
    Do generic Activity creation stuff that all Activities do<br />
    Then load up the view from res/layout/main.xml for display.</p>
<p>(The &#8220;savedInstanceState&#8221; isn&#8217;t applicable right now; if you&#8217;re curious, you can use it to save things like the content of text fields when your view is destroyed &#8211; for example, if the user takes a phone call or rotates the screen &#8211; and restore them later when the user returns to your activity).</p>
<p>In particular, when<br />
setContentView(R.layout.main);<br />
runs, it gives us access in code to the views inside that layout. In order to access those views, we need to reference them with the findViewById method:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Button</span> postTweet <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Button</span><span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">TwitterPosterPostButton</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">final</span> EditText tweetEditText <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>EditText<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">TwitterPosterMessageText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>As you type, Eclipse may give you errors for classses like Button or EditText that haven&#8217;t been imported yet. Just use the &#8220;quick fix&#8221; (Command-1 or Ctrl-1, or hover over the underlined error) to automatically add the missing import statements.</p>
<p>Now that we have our EditText and Button, let&#8217;s set an action when the user clicks on the button. For now, let&#8217;s just have it Toast us the status message (a Toast is an Android popup that displays a message for a few seconds, then disappears &#8211; similar to Growl on a Mac).</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">postTweet.<span style="color: #006633;">setOnClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> OnClickListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span> twitterStatus <span style="color: #339933;">=</span> tweetEditText.<span style="color: #006633;">getText</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: #339933;">;</span>
        Toast.<span style="color: #006633;">makeText</span><span style="color: #009900;">&#40;</span>TwitterPoster.<span style="color: #000000; font-weight: bold;">this</span>,
            <span style="color: #0000ff;">&quot;You tweeted &quot;</span> <span style="color: #339933;">+</span> twitterStatus, 
            Toast.<span style="color: #006633;">LENGTH_LONG</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Go ahead and try that out.</p>
<div id="attachment_277" class="wp-caption alignnone" style="width: 214px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/emulator-toast.png"><img class="size-medium wp-image-277" title="emulator-toast" src="http://media.activefrequency.com/wp-uploads/2009/10/emulator-toast-204x300.png" alt="OnClickListener &#038; Toast in action" width="204" height="300" /></a><p class="wp-caption-text">The OnClickListener and Toast in action</p></div>
<p>The message, of course, is a lie right now; we haven&#8217;t written the code that actually posts to Twitter, but this is a good start. In <a href="http://activefrequency.com/blog/2009/ground-up-android-part-5-tweeting-and-debugging/">Part 5</a>, we&#8217;ll write the Twitter code and learn how to debug Android code.</p>
<p><strong>On to <a href="http://activefrequency.com/blog/2009/ground-up-android-part-5-tweeting-and-debugging/">Part 5</a>!</strong></p>
<h2>Code Recap</h2>
<p>In case you&#8217;ve drifted a bit, here&#8217;s what you should have for TwitterPoster.java:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">com.activefrequency.android.demos.twitternator</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.app.Activity</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.os.Bundle</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.view.View.OnClickListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.Button</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.EditText</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">android.widget.Toast</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TwitterPoster <span style="color: #000000; font-weight: bold;">extends</span> Activity <span style="color: #009900;">&#123;</span>
    <span style="color: #008000; font-style: italic; font-weight: bold;">/** Called when the activity is first created. */</span>
    @Override
    <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>
        <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>
        setContentView<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">layout</span>.<span style="color: #006633;">main</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Button</span> postTweet <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Button</span><span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">TwitterPosterPostButton</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> EditText tweetEditText <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>EditText<span style="color: #009900;">&#41;</span> findViewById<span style="color: #009900;">&#40;</span>R.<span style="color: #006633;">id</span>.<span style="color: #006633;">TwitterPosterMessageText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        postTweet.<span style="color: #006633;">setOnClickListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> OnClickListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onClick<span style="color: #009900;">&#40;</span><span style="color: #003399;">View</span> v<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #003399;">String</span> twitterStatus <span style="color: #339933;">=</span> tweetEditText.<span style="color: #006633;">getText</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: #339933;">;</span>
			    Toast.<span style="color: #006633;">makeText</span><span style="color: #009900;">&#40;</span>TwitterPoster.<span style="color: #000000; font-weight: bold;">this</span>, 
                                <span style="color: #0000ff;">&quot;You tweeted &quot;</span><span style="color: #339933;">+</span>twitterStatus, 
                                Toast.<span style="color: #006633;">LENGTH_LONG</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/ground-up-android-part-4-writing-the-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ground-Up Android, Part 3: Describing Your Layout</title>
		<link>http://activefrequency.com/blog/2009/ground-up-android-part-3-describing-your-layout/</link>
		<comments>http://activefrequency.com/blog/2009/ground-up-android-part-3-describing-your-layout/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:16:39 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[twitternator-tutorial]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=252</guid>
		<description><![CDATA[This is part 3 of a 5-part series on introductory Android development. If you&#8217;re just arriving, you should head on over to Part 1.
In Part 2, we started an Android project, poked around it a little, and launched an emulator. Now we&#8217;ll move on to making the app look like what we want.
You&#8217;ll notice I [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is part 3 of a <a href="http://activefrequency.com/blog/tag/twitternator-tutorial/">5-part series</a> on introductory Android development. If you&#8217;re just arriving, you should head on over to <a href="http://activefrequency.com/blog/2009/ground-up-android-getting-started-with-app-development">Part 1</a>.</em></p>
<p>In <a href="http://activefrequency.com/blog/2009/ground-up-android-part-2-our-first-project/">Part 2</a>, we started an Android project, poked around it a little, and launched an emulator. Now we&#8217;ll move on to making the app look like what we want.</p>
<p>You&#8217;ll notice I titled this part &#8220;Describing Your Layout,&#8221; not &#8220;Coding Your Layout&#8221; or &#8220;Programming Your Views.&#8221; This is because Android gives you the tools to define most of the characteristics of your Activity&#8217;s visuals in descriptive, not procedural terms. This helps speed up development, thanks to the nice GUI-based tools for layout, and helps you keep your programming logic out of the places you define your application&#8217;s outward appearances (and vice versa). It&#8217;s important to know that you could create your entire app in Java, writing the descriptive code for your layout procedurally in your Activity instead, but it&#8217;s a much better idea to keep things separate wherever possible.</p>
<h2>The resources</h2>
<p>We&#8217;re going to build a basic Twitter client, so let&#8217;s make it look like one. Let&#8217;s switch back into Eclipse and poke around at what we have so far. You&#8217;ll recall that besides our Activity&#8217;s Java file, we have layout and strings files in the res/layout and res/values folders. Let&#8217;s go check them out.</p>
<p>Here&#8217;s the basic layout the wizard created for us in res/layout/main.xml:</p>
<div id="attachment_264" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/xml-layout.png"><img class="size-medium wp-image-264" title="xml-layout" src="http://media.activefrequency.com/wp-uploads/2009/10/xml-layout-300x125.png" alt="the main layout xml" width="300" height="125" /></a><p class="wp-caption-text">The main layout xml</p></div>
<p><span id="more-252"></span><br />
You&#8217;ll notice there&#8217;s also a Layout graphical view for that, which you can switch from/to using the tabs at the bottom of the pane:</p>
<div id="attachment_265" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/layout-preview.png"><img class="size-medium wp-image-265" title="layout-preview" src="http://media.activefrequency.com/wp-uploads/2009/10/layout-preview-300x217.png" alt="the graphical view" width="300" height="217" /></a><p class="wp-caption-text">The graphical view</p></div>
<p>It has its limitations, but it&#8217;s a good way to get a quick glance at your UI without even firing up an emulator. For example, we can change the pre-generated strings; open up the res/values/strings.xml file and change the &#8220;hello&#8221; string to something more useful:</p>
<div id="attachment_266" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/strings-editor.png"><img class="size-medium wp-image-266" title="strings-editor" src="http://media.activefrequency.com/wp-uploads/2009/10/strings-editor-300x71.png" alt="editing strings" width="300" height="71" /></a><p class="wp-caption-text">Editing strings</p></div>
<p>You can use the helpful XML properties editor, or just edit the source XML once you&#8217;re more comfortable.<br />
Save the file, then go back to the preview of the main.xml:</p>
<div id="attachment_267" class="wp-caption alignnone" style="width: 372px"><img class="size-full wp-image-267" title="updated-preview" src="http://media.activefrequency.com/wp-uploads/2009/10/updated-preview.png" alt="The preview updates right away." width="362" height="157" /><p class="wp-caption-text">The preview updates right away.</p></div>
<p>Handy &#8211; we didn&#8217;t even have to switch back into the emulator to check our changes out.</p>
<h2>Placing widgets</h2>
<p>It&#8217;s still not much of a screen yet, though. Let&#8217;s add a text field and a button to the view. The easiest way to do that is just to drag them from the palette of Views on the left of the preview right onto your layout.</p>
<div id="attachment_268" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/layout-editor-widgets.png"><img class="size-medium wp-image-268" title="layout-editor-widgets" src="http://media.activefrequency.com/wp-uploads/2009/10/layout-editor-widgets-300x294.png" alt="You can drag widgets right onto the layout pane." width="300" height="294" /></a><p class="wp-caption-text">You can drag widgets right onto the layout pane.</p></div>
<p>If you click to the source view, you can see the XML it generated for those items right there. If you go back to Debug (Run-&gt; Debug) and open the emulator, you&#8217;ll see our new text box and button there, just like in the preview pane.</p>
<h2>Prettying things up</h2>
<p>So far so good, but let&#8217;s pretty things up a little before we move on.</p>
<p>Things we&#8217;ll fix in this layout:<br />
* Meaningful IDs for items<br />
* Useful button text<br />
* &#8220;hint&#8221; text for the text box (grey text that disappears when the user starts typing)<br />
* Fixed width for the textbox so it isn&#8217;t expanding/contracting as we type<br />
* Layout margins on things so the display can &#8220;breathe&#8221; a little &#8212; this is important both visually, and so fat-fingered users can select the on-screen item they mean to.</p>
<p>You can do this with the Properties editor, which shows below the Layout view by default, or by editing the source XML to look like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;LinearLayout</span></span>
<span style="color: #009900;">	<span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">android:orientation</span>=<span style="color: #ff0000;">&quot;vertical&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span>
<span style="color: #009900;">	<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;TextView</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;@string/hello&quot;</span> </span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_margin</span>=<span style="color: #ff0000;">&quot;12dip&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;EditText</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/TwitterPosterMessageText&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_margin</span>=<span style="color: #ff0000;">&quot;12dip&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;fill_parent&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:hint</span>=<span style="color: #ff0000;">&quot;What are you doing right now?&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/EditText<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;Button</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:text</span>=<span style="color: #ff0000;">&quot;Tweet!&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:id</span>=<span style="color: #ff0000;">&quot;@+id/TwitterPosterPostButton&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_margin</span>=<span style="color: #ff0000;">&quot;12dip&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_width</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span></span>
<span style="color: #009900;">		<span style="color: #000066;">android:layout_height</span>=<span style="color: #ff0000;">&quot;wrap_content&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/Button<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/LinearLayout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Two things to notice here:<br />
We specified our sizes in &#8220;dip&#8221; &#8212; density-independent pixels. This lets us indicate how much space something should use regardless of whether the user is on a high-resolution but small screen (like a shiny new high-end phone) or a low-res but big screen (like a TV). This is a good habit to get in to; it&#8217;ll simplify developing and testing applications that will work on present and future Android devices, regardless of resolution or size.</p>
<p>You&#8217;ll also notice that while we used the strings.xml file before with the default TextView, we&#8217;re using hard-coded messages for the EditText&#8217;s hint and the Button&#8217;s text. If we were making a proper internationalizable application, we&#8217;d use the Strings file to store those, but we&#8217;re going to keep things simple for the demo.</p>
<p>One more thing: we still have a pretty generic looking icon for our app if you look around the emulator&#8217;s program&#8217;s list:</p>
<div id="attachment_270" class="wp-caption alignnone" style="width: 91px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/twitternator-icon.png"><img class="size-full wp-image-270" title="twitternator-icon" src="http://media.activefrequency.com/wp-uploads/2009/10/twitternator-icon.png" alt="Yawn." width="81" height="73" /></a><p class="wp-caption-text">Yawn.</p></div>
<p>That just won&#8217;t do for our cutting-edge Twitter client. I found a pretty good-looking set called <a href="http://www.chris-wallace.com/2009/01/02/tweeties-a-free-twitter-icon-set/" target="_blank">Tweeties</a> by Chris Wallace, which has some nice looking icons and is licensed under a <a href="http://creativecommons.org/licenses/by-nc-sa/3.0/us/">CC Attribution-Noncommercial-Share Alike license</a>:</p>
<div id="attachment_271" class="wp-caption alignnone" style="width: 58px"><img class="size-full wp-image-271" title="icon" src="http://media.activefrequency.com/wp-uploads/2009/10/icon.png" alt="Much better!" width="48" height="48" /><p class="wp-caption-text">Better!</p></div>
<p>Let&#8217;s use this or one of the other 48&#215;48 .png files in the set. Rename it icon.png, and overwrite the res/drawable/icon.png file. You can drag the file straight from the Finder on OS X or the Windows Explorer into the appropriate folder in the project explorer panel in Eclipse.</p>
<p>Then let&#8217;s also use that icon as part of our Tweet button by setting it as the drawable_left of the button, either in the Properties editor or by manually editing the XML with this property:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">android:drawableLeft=&quot;@drawable/icon&quot;</pre></div></div>

<p>Then go ahead and Debug the project again (Run-&gt;Debug) and pop back into the emulator:</p>
<div id="attachment_272" class="wp-caption alignnone" style="width: 212px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/emulator-screenshot-better-look.png"><img class="size-medium wp-image-272" title="emulator-screenshot-better-look" src="http://media.activefrequency.com/wp-uploads/2009/10/emulator-screenshot-better-look-202x300.png" alt="The finished layout" width="202" height="300" /></a><p class="wp-caption-text">The finished layout</p></div>
<p>Well, that&#8217;s shaping up. Go ahead and mess around with that a bit. Of course, for now it&#8217;s just a pretty face &#8212; we still have to tell our code what to actually do. We&#8217;ll get into that in <a href="http://activefrequency.com/blog/2009/ground-up-android-part-4-writing-the-code/">Part 4</a>.</p>
<p><strong>On to <a href="http://activefrequency.com/blog/2009/ground-up-android-part-4-writing-the-code/">Part 4</a>!</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/ground-up-android-part-3-describing-your-layout/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ground-Up Android, Part 2: Our First Project</title>
		<link>http://activefrequency.com/blog/2009/ground-up-android-part-2-our-first-project/</link>
		<comments>http://activefrequency.com/blog/2009/ground-up-android-part-2-our-first-project/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:14:43 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[twitternator-tutorial]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=232</guid>
		<description><![CDATA[This is part 2 of a 5-part series on introductory Android development. If you&#8217;re just arriving, you should head on over to Part 1. 
In the first part of the tutorial, we got Eclipse, the Android SDK, and the ADT set up. In this part, we&#8217;ll get into our environment, create our first project and [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is part 2 of a <a href="http://activefrequency.com/blog/tag/twitternator-tutorial/">5-part series</a> on introductory Android development. If you&#8217;re just arriving, you should head on over to <a href="http://activefrequency.com/blog/2009/ground-up-android-getting-started-with-app-development">Part 1</a>. </em></p>
<p>In the <a href="http://activefrequency.com/blog/2009/ground-up-android-getting-started-with-app-development/">first part</a> of the tutorial, we got Eclipse, the Android SDK, and the ADT set up. In this part, we&#8217;ll get into our environment, create our first project and poke around in it, and test out the Android emulator.</p>
<h2>Fire It Up</h2>
<p>Go ahead and fire up Eclipse, and if it asks, choose a workspace (the default&#8217;s probably fine for now). Click on the &#8220;new android project&#8221; button or go to File -&gt; New -&gt; Android Project.</p>
<div id="attachment_237" class="wp-caption alignnone" style="width: 314px"><img class="size-full wp-image-237  " title="new android project." src="http://media.activefrequency.com/wp-uploads/2009/10/new-project-button.png" alt="Click the New Android Project button." width="304" height="178" /><p class="wp-caption-text">Click the New Android Project button.</p></div><br />
<span id="more-232"></span><br />
Choose a name and settings for your project &#8211; we&#8217;ll call ours Twitternator. I&#8217;m choosing to target Android 1.5 for now, since that&#8217;s what&#8217;s running on most current production phones. 1.6 allows for some neat new features, but nothing we&#8217;re going to use here, so we may as well go for the lowest baseline possible. We&#8217;ll also leave out the Google APIs for now (those are used for Maps), since we won&#8217;t need them.</p>
<p><div id="attachment_239" class="wp-caption alignnone" style="width: 283px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/new-android-project.png"><img class="size-medium wp-image-239" title="new-android-project" src="http://media.activefrequency.com/wp-uploads/2009/10/new-android-project-273x300.png" alt="The New Android Project screen." width="273" height="300" /></a><p class="wp-caption-text">The New Android Project screen.</p></div>
<p>By targeting a specific SDK version and specific vendor libraries, developers have the ability to write apps for a base platform without worrying about users on older hardware and software &#8211; they simply won&#8217;t see the app in the Android Market, and will see a helpful error if they try to install it manually.</p>
<p>Then click Finish (there&#8217;s also an option to create testing code, which we&#8217;ll skip for now) and we&#8217;ll explore the structure of the folders we have now.</p>
<div id="attachment_240" class="wp-caption alignnone" style="width: 258px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/project-layout.png"><img class="size-medium wp-image-240" title="project-layout" src="http://media.activefrequency.com/wp-uploads/2009/10/project-layout-248x300.png" alt="The structure of the project in Eclipse" width="248" height="300" /></a><p class="wp-caption-text">The structure of the project in Eclipse</p></div>
<p>The AndroidManifest.xml describes your application to the rest of the Android system &#8211; what version of the OS it supports, what permissions it needs (for Internet access, GPS information, etc.), how other applications will use it (via Intents and ContentProviders, advanced ways for applications to call each other and share data), what the different screens (Activities) are in the app, and so on.</p>
<p>&#8220;src&#8221; contains our Java code, and the wizard pre-created an Activity for us. Think of Activities as the code representation of one screen of your application. Here&#8217;s the pre-created outline of an activity, which simply tells the system to render the view from a layout file called &#8220;main&#8221; (more on those in Part 3).</p>
<div id="attachment_241" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/twitter-poster-activity.png"><img class="size-medium wp-image-241" title="twitter-poster-activity" src="http://media.activefrequency.com/wp-uploads/2009/10/twitter-poster-activity-300x125.png" alt="The initial code for our Activity" width="300" height="125" /></a><p class="wp-caption-text">The initial code for our Activity</p></div>
<p>The &#8220;res&#8221; folder contains non-code resources; usually &#8220;drawable&#8221; will contain image files, &#8220;layout&#8221; will contain XML files you can use to build UI for your application in an easy-to-read way rather than writing it all out in Java code, and &#8220;values&#8221; will contain things like internationalized strings files, color definitions, or theme styling definitions to apply to your views.</p>
<p>Finally, the &#8220;gen&#8221; folder contains automatically created code you can think of as placeholders for items in your res folder, so you can easily point to a particular button, string, or image from your code. This speeds up references to that information and makes code completion easy, and it&#8217;s done automatically in the background while you work.</p>
<p>We actually already have a working Android app created here. Let&#8217;s test it out in the emulator.</p>
<h2>Emulation Nation</h2>
<p>There are already a half dozen phones in the wild running Android; dozens more will be coming out in the months to come. Each one has a variety of screen resolutions, software versions, and hardware controls. There&#8217;s no substitute for testing on actual devices, of course, but the Android SDK includes a good solution for modeling a variety of these in software.</p>
<p>The emulator in Android is based on the open-source qemu emulator, and you can create models called AVDs (Android Virtual Devices) with a variety of hardware and software capabilities. For this project, we&#8217;ll create a basic Android 1.6 device with an HVGA screen, a 32MB SD card, and the basic APIs.</p>
<div id="attachment_243" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/avd-manager-menu.png"><img class="size-medium wp-image-243" title="avd-manager-menu" src="http://media.activefrequency.com/wp-uploads/2009/10/avd-manager-menu-300x211.png" alt="Where the AVD Manager is hiding." width="300" height="211" /></a><p class="wp-caption-text">Where the AVD Manager is hiding.</p></div>
<p>Open the AVD Manager and create the new device.</p>
<div id="attachment_244" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/avd-creator.png"><img class="size-medium wp-image-244" title="avd-creator" src="http://media.activefrequency.com/wp-uploads/2009/10/avd-creator-300x173.png" alt="The AVD Creator." width="300" height="173" /></a><p class="wp-caption-text">The AVD Creator.</p></div>
<p>Then go back to the Java view of our project. Let&#8217;s go back to TwitterPoster.java and debug it from Run -&gt; Debug -&gt; Android Project. It should auto-launch the emulator here.<br />
Give it a minute for the first boot, then go ahead and your app should launch right up:</p>
<p><a href="http://media.activefrequency.com/wp-uploads/2009/10/emulator-running.png"><img class="alignnone size-medium wp-image-246" title="emulator-running" src="http://media.activefrequency.com/wp-uploads/2009/10/emulator-running-300x219.png" alt="emulator-running" width="300" height="219" /></a></p>
<p>Aww, look, our first running Android process! You should go have that <a href="http://www.abcbronze.com/">bronzed</a> to commemorate the occasion.</p>
<p>Usually, you&#8217;ll keep the emulator open for your entire development session. One really great thing about debugging Android applications is that you can quickly edit your code, which builds in the background, then push it into a running instance of the emulator and see the results in seconds. You don&#8217;t have to wait to rebuild your code or launch new emulators; you get feedback nearly instantly.</p>
<p>So far, we&#8217;ve gotten our environment set up, explored the project layout, and launched the emulator. In our <a href="http://activefrequency.com/blog/2009/ground-up-android-part-3-describing-your-layout/">next post</a>, we&#8217;ll pretty things up and explore the layout editing tools.</p>
<p><strong><a href="http://activefrequency.com/blog/2009/ground-up-android-part-3-describing-your-layout/">On to Part 3!</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/ground-up-android-part-2-our-first-project/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>Ground-Up Android: Getting Started with App Development</title>
		<link>http://activefrequency.com/blog/2009/ground-up-android-getting-started-with-app-development/</link>
		<comments>http://activefrequency.com/blog/2009/ground-up-android-getting-started-with-app-development/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:06:56 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[twitternator-tutorial]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=227</guid>
		<description><![CDATA[This is part 1 of a 5-part series on introductory Android development.
Thinking about testing the waters with Android development? Jump right in. We&#8217;ll build a neat little application that interacts with a web service.
Which one? Twitter, of course.
This is a web form of a talk I gave with Henry Cipolla, CTO of Localytics, at BarCamp [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is part 1 of a <a href="http://activefrequency.com/blog/tag/twitternator-tutorial/">5-part series</a> on introductory Android development.</em></p>
<p>Thinking about testing the waters with Android development? Jump right in. We&#8217;ll build a neat little application that interacts with a web service.</p>
<div id="attachment_299" class="wp-caption alignnone" style="width: 310px"><a href="http://media.activefrequency.com/wp-uploads/2009/10/android-fail-whale.png"><img src="http://media.activefrequency.com/wp-uploads/2009/10/android-fail-whale-300x225.png" alt="Yup." title="android-fail-whale" width="300" height="225" class="size-medium wp-image-299" /></a><p class="wp-caption-text">Yup.</p></div>
<p>Which one? Twitter, of course.</p>
<p>This is a web form of a talk I gave with Henry Cipolla, CTO of Localytics, at BarCamp Boston 4 and in a longer form at FITC Mobile 2009, updated to cover the 1.6 (&#8221;Donut&#8221;) release of the Android SDK. The slideshow portion of that talk covers the basic concepts of the platform and <a href="http://prezi.com/ucpzhmmqxxob/">slides are available online</a>. I recommend checking it out.</p>
<p><span id="more-227"></span></p>
<h2>Who is this for?</h2>
<p>I assume you&#8217;re familiar with development in general, and you&#8217;ll find it easiest if you&#8217;ve done a little Java programming before and have actually used an Android device, but I assume no in-depth experience with the platform.</p>
<h2>Platform Basics</h2>
<p>The slides linked to above give a good visual overview, too, and the <a href="http://developer.android.com/index.html">Android Developers website</a> is an invaluable resource for finding more details on everything Android development related. But here&#8217;s the absolute minimum you need to know to get started.</p>
<p>The Android Platform is a full software stack for mobile devices that includes a Linux operating system, hardware drivers, and a bunch of neat low-level libraries you&#8217;ll probably never touch directly. It provides end users with a nice interface and handy applications to do things like browse the web, sync their email, and even make phone calls.</p>
<p>It also provides a way for users to securely run applications of their choice, simultaneously, and a set of tools and libraries developers can use to build their own applications &#8212; powerful enough to replicate or even replace many of the built-in &#8220;core&#8221; applications like the home screen or phone dialer.</p>
<p>Android applications are written in <a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> (J2SE, not a pared-down Java Mobile/Micro (<a href="http://java.sun.com/javame/index.jsp">Java ME</a>) as found on many low-end phones) using an open-source J2SE implementation based on <a href="http://harmony.apache.org/">Apache Harmony</a> along with tons of Android-specific libraries for things like UI and handy third-party libraries for things like HTTP requests and JSON parsing. That Java code is compiled and then transformed into Android-specific files in a format called .dex, and runs on the phone in a highly optimized VM runtime called Dalvik. Luckily, you&#8217;ll almost never have to think about any of those pieces in between writing your code and running it on the phone, since the tools take care of them for you.</p>
<p>Your code eventually runs in its own private highly-optimized virtual machine &#8212; it has its own memory space, and even runs as its own system user. This keeps bad code from blowing up the rest of the system and keeps your code secure from malicious software, eliminating risks from things like buffer overflow attacks or memory leaks that can affect other platforms.</p>
<h2>Why Android?</h2>
<p>The unspoken question here is usually &#8220;Why not the iPhone?&#8221; From a developer&#8217;s perspective, they both offer very good development environments and libraries, powerful testing and debugging tools, and a similar baseline of fairly speedy hardware devices. But the fact is, right now there are many times as many iPhone users and applications as there are Android users and apps. And there&#8217;s just plain more money being spent on iPhone apps right now, so from a business perspective, you absolutely can&#8217;t rule the iPhone out. There are really a few reasons to think seriously about Android for an application, though:</p>
<ul>
<li><strong>Store independence</strong>. Your app can never be caught up in &#8220;approval limbo&#8221; &#8211; there&#8217;s no waiting period and you can update your app whenever you want. And if you&#8217;re unhappy with the Android Market itself, you can look to third-party stores like SlideME or even distribute apps for users to install themselves.</li>
<li><strong>Device independence</strong>. There&#8217;s only one iPhone device (or more accurately, 3 phone and 3 iPod Touch models with nearly-identical appearances and hardware) on one carrier (AT&amp;T). Android is on devices from several major and minor manufacturers in a variety of form factors, and will be on phones for T-Mobile, Verizon, and Sprint by the end of the year.</li>
<li><strong>J2SE</strong>. Love it or hate it, there&#8217;s a lot of resources for learning it, tons of well-tested libraries, and no need to learn Objective C.</li>
<li><strong>Background processes</strong>. There are things you just can&#8217;t do with push notification.</li>
<li><strong>Little pond</strong>. Now that the initial App Store rush is over, it can be difficult to get attention in a store with dozens of new applications in your category every day. The Android Market is comparatively uncrowded, and the user base is likely to grow quickly as new carriers and devices come to market. While Active Frequency&#8217;s <a href="http://activefrequency.com/rockout/">RockOut</a> application was the only virtual guitar on the Android Market for several months, there are dozens of competitors for the iPhone.</li>
</ul>
<p>Rather than talk the platform up any more, I&#8217;ll jump into writing an app and explain features as I go through it. For now, I&#8217;ll just say Android is an open platform and has some cool features like the Intents system, good native UI widgets, a sane and reasonable permissions system, and background processes, along with safeguards against bad code and access to a full J2SE stack.</p>
<h2>What will I learn?</h2>
<p>The point of this series isn&#8217;t to memorize APIs or the right sequences of incantations to do specific tasks, it&#8217;s to learn the general process of writing apps for Android.</p>
<p>Specifically, I tell the people watching this presentation live to keep an eye on the quick &#8220;prototype-run-test-edit-run&#8230;&#8221; cycle the tools make quick and simple, on the ease of debugging and getting useful, filterable console output, and in general on getting the a feel for effectively using the build tools and environment to get started quickly. You won&#8217;t learn the intricacies of all available tools and libraries in this one tutorial, and there&#8217;s no substitute for reading the documentation &#8212; but the documentation can&#8217;t show you what a typical development cycle looks like.</p>
<h2>Know your tools</h2>
<p>Most Android developers are using Google&#8217;s excellent tool chain. You can ignore some or all of it and write your code in the editor of your choice, interacting with build scripts and testing tools only when you want to, but the tools handle a lot of boring parts for you and give you one interface to handle a lot of functionality.</p>
<p>You&#8217;ll want a recent version (3.4 or 3.5) of the <a href="http://www.eclipse.org/downloads/">Eclipse IDE</a> (Integrated Development Environment) for J2SE, the <a href="http://developer.android.com/sdk/1.6_r1/index.html">Android SDK</a>, and the Eclipse <a href="http://developer.android.com/sdk/1.6_r1/installing.html#InstallingADT">ADT plugin</a> to interface with those tools and provide project templates. Be sure to check out Google&#8217;s  <a href="http://developer.android.com/sdk/1.6_r1/installing.html">complete installation instructions</a> for details.</p>
<p>Alternatively, you can install the all-in-one <a href="http://developer.motorola.com/docstools/motodevstudio/">Motodev Studio</a>, which includes all of those parts in a simple installer. However, I can&#8217;t really recommend that option right now as it&#8217;s still in beta and is a full version behind the SDK from Google (1.5, vs. 1.6) as of this writing.  For this tutorial, I&#8217;m using Eclipse 3.5 for Mac OS X (Cocoa/64-bit) with ADT 0.9.3 and SDK 1.6r1 &#8212; the latest production releases as of October 1 2009, but you should be able to follow along just fine from Windows or your Linux/Unix of choice once you set up Eclipse, the SDK and the ADT.</p>
<p>&#8230; OK, all set? Great. Let&#8217;s move on to <a href="http://activefrequency.com/blog/2009/ground-up-android-part-2-our-first-project/">Part 2</a> and start our project.</p>
<p><strong><a href="http://activefrequency.com/blog/2009/ground-up-android-part-2-our-first-project/">On to Part 2!</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/ground-up-android-getting-started-with-app-development/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Code and Slides from FITC Mobile 2009</title>
		<link>http://activefrequency.com/blog/2009/code-and-slides-from-fitc-mobile-200/</link>
		<comments>http://activefrequency.com/blog/2009/code-and-slides-from-fitc-mobile-200/#comments</comments>
		<pubDate>Mon, 14 Sep 2009 19:10:17 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=221</guid>
		<description><![CDATA[For those of you checking out our presentations at FITC Mobile, here&#8217;s the source code for the first session on introductory Android development, and the more complete source code for the second session on Android homescreen appwidgets.
The slides for our intro presentation are hosted on Prezi. Henry will be doing a narrated screencast of his [...]]]></description>
			<content:encoded><![CDATA[<p>For those of you checking out our presentations at FITC Mobile, here&#8217;s the <a href="http://static.activefrequency.com/fitc/twitter-intro-code.zip">source code for the first session</a> on introductory Android development, and the more complete <a href="http://static.activefrequency.com/fitc/twitter-widget-final-complete.zip">source code for the second session</a> on Android homescreen appwidgets.</p>
<p>The slides for our intro presentation are <a href="http://prezi.com/ucpzhmmqxxob/">hosted on Prezi</a>. Henry will be doing a narrated screencast of his part at some point in the next few weeks, and I&#8217;ll be doing a more complete writeup of the code portion with notes in a later post here on Active Frequency&#8217;s blog.</p>
<p>You&#8217;ll notice I linked in specific files from JTwitter rather than just including the .jar; there&#8217;s a lot of unnecessary code in the .jar and the J2SE source is a little lighter and cleaner, and hopefully makes it especially clear what the Twitter client is actually doing.</p>
<p>The demos use the <a href="http://www.winterwell.com/software/jtwitter.php">JTwitter</a> library (LGPL), and the icon is from a great Creative Commons set called <a href="http://www.chris-wallace.com/2009/01/02/tweeties-a-free-twitter-icon-set/">Tweeties</a> by Chris Wallace.</p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/code-and-slides-from-fitc-mobile-200/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Active Frequency at FITC Mobile 2009</title>
		<link>http://activefrequency.com/blog/2009/active-frequency-at-fitc-mobile-2009/</link>
		<comments>http://activefrequency.com/blog/2009/active-frequency-at-fitc-mobile-2009/#comments</comments>
		<pubDate>Sat, 12 Sep 2009 22:27:12 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=214</guid>
		<description><![CDATA[
FITC Mobile 2009 kicks off tomorrow morning in Toronto. I&#8217;ll be leading two developer-geared sessions: Diving Into Android Development (with Henry Cipolla of Localytics) and Android Homescreen AppWidgets.
I&#8217;ll also be posting slides, notes, and code from the sessions to this blog during the conference, and occasionally Tweeting from our new Twitter account.
Come by and say [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img class="size-full wp-image-215 aligncenter" title="fitc-mobile-logo" src="http://media.activefrequency.com/wp-uploads/2009/09/fitc-mobile-logo.png" alt="fitc-mobile-logo" width="321" height="266" /></p>
<p><a href="http://www.fitc.ca/events/about/?event=92">FITC Mobile 2009</a> kicks off tomorrow morning in Toronto. I&#8217;ll be leading two developer-geared sessions: <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=92&amp;presentation_id=1005">Diving Into Android Development</a> (with Henry Cipolla of <a href="http://www.localytics.com/">Localytics</a>) and <a href="http://www.fitc.ca/events/presentations/presentation.cfm?event=92&amp;presentation_id=1006">Android Homescreen AppWidgets</a>.</p>
<p>I&#8217;ll also be posting slides, notes, and code from the sessions to this blog during the conference, and occasionally Tweeting from <a href="http://twitter.com/activefrequency/">our new Twitter account</a>.</p>
<p>Come by and say hi if you&#8217;re going to be there!</p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/active-frequency-at-fitc-mobile-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Things That Are Awesome</title>
		<link>http://activefrequency.com/blog/2009/things-that-are-awesome/</link>
		<comments>http://activefrequency.com/blog/2009/things-that-are-awesome/#comments</comments>
		<pubDate>Wed, 09 Sep 2009 17:52:18 +0000</pubDate>
		<dc:creator>Kevin Grinberg</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=212</guid>
		<description><![CDATA[Awesome: DC App Store, a repository of apps and mashups based on DC data feeds.
My fave: Park It DC, possible by the District providing useful data feeds.
]]></description>
			<content:encoded><![CDATA[<p>Awesome: <a href="http://appstore.dc.gov/">DC App Store</a>, a repository of apps and mashups based on DC data feeds.</p>
<p>My fave: <a href="http://www.parkitdc.com/">Park It DC</a>, possible by the District providing <a href="http://dcatlas.dcgis.dc.gov/metadata/ParkingMeter.html">useful</a> <a href="http://data.octo.dc.gov/Metadata.aspx?id=4">data</a> <a href="http://dcatlas.dcgis.dc.gov/metadata/RPPBlocks.html">feeds</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/things-that-are-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>15 New Kick-Ass Cupcake Features</title>
		<link>http://activefrequency.com/blog/2009/15-new-kick-ass-android-cupcake-features/</link>
		<comments>http://activefrequency.com/blog/2009/15-new-kick-ass-android-cupcake-features/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 03:15:41 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=169</guid>
		<description><![CDATA[Android&#8217;s much ballyhooed 1.5 release (aka Cupcake) seems to be imminent. Last week, Google released a preview version of the SDK, and I&#8217;ve dug through it a bit and kicked the tires. In honor of the impending 1.5 release, here are 15 neat features I really dig.

Five New User Features that Kick Ass
Here are some [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-182" title="splashscreen-logo" src="http://media.activefrequency.com/wp-uploads/2009/04/splashscreen-logo.gif" alt="splashscreen-logo" width="253" height="53" />Android&#8217;s much ballyhooed 1.5 release (aka Cupcake) seems to be imminent. Last week, Google released a <a href="http://developer.android.com/sdk/preview/">preview</a> version of the SDK, and I&#8217;ve dug through it a bit and kicked the tires. In honor of the impending 1.5 release, here are 15 neat features I really dig.</p>
<p><span id="more-169"></span></p>
<h3>Five New User Features that Kick Ass</h3>
<p>Here are some features Android end-users will really like, although they shouldn&#8217;t matter much to developers.</p>
<div class="alignleft" style="padding-right:5px;"><a href="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-keyboard.gif"><img class="alignnone size-thumbnail wp-image-177" title="cupcake-keyboard" src="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-keyboard-150x150.gif" alt="cupcake-keyboard" width="150" height="150" /></a><br />
<hr /><a href="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-music-widget.jpg"><img class="alignnone size-thumbnail wp-image-178" title="cupcake-music-widget" src="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-music-widget-150x150.jpg" alt="cupcake-music-widget" width="150" height="150" /></a></div>
<ul>
<li><strong>A2DP</strong> &#8211; AKA Bluetooth stereo, so you can listen to music and take phone calls without cords. No screenshots to demo, and can&#8217;t test it in the emulator, but it&#8217;s on the <a href="http://source.android.com/roadmap/cupcake">feature list</a>. This is even more crucial for the G1 than for the iPhone, since it doesn&#8217;t have a built-in standard headphone jack.</li>
<li><strong>Soft Keyboard </strong>- Terrible for typing real emails, but sometimes you don&#8217;t want to slide open the keyboard just to mash out a quick one-handed SMS.</li>
<li><strong>Music Player Widget</strong> &#8211; Along with A2DP, easy access to the music player makes Android phones a more viable replacement for an MP3 player.</li>
<li><strong>Smart Folders</strong> &#8211; Starred Contacts Folders, for example, which may finally make a competent &#8220;speed dial&#8221; replacement. The folder&#8217;s contacts update dynamically when you change your contacts list, unlike the current release, where you&#8217;d have to go add or remove the contact in the folder separately.</li>
<li><strong>Camcorder</strong> &#8211; with YouTube uploading. Can&#8217;t run this in the emulator, but the application is there and it&#8217;s on the feature list.</li>
</ul>
<h3>Five New Developer Features that Kick Ass</h3>
<p>These features will make programmers happy. The impact from these will probably take a few days/weeks after release to matter to end users while developers scramble to write code once the final release of the SDK comes out.</p>
<div class="alignright"><a href="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-sdk-targets.gif"><img class="alignnone size-thumbnail wp-image-179" title="cupcake-sdk-targets" src="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-sdk-targets-150x150.gif" alt="cupcake-sdk-targets" width="150" height="150" /></a></div>
<ul>
<li><strong>SDK Targeting</strong> &#8211; A major developer concern is compatibility, especially as new handset manufacturers add their own proprietary software and as some may lock the core OS at a different release than others. You can make one app for SDK 1.1 base devices, and a different one for SDK 1.5 devices that include the Google APIs, for example, and if the user&#8217;s software doesn&#8217;t match up they can&#8217;t run and crash your app.</li>
<li><strong>AppWidget Framework</strong> &#8211; Not just for the Home Screen; there might be some nifty uses for in-app embedding of one app inside another that I can&#8217;t even fully comprehend yet (maybe a third-party drum sequencer AppWidget inside <a href="http://activefrequency.com/rockout/">RockOut</a>, for example).</li>
<li><strong>JetPlayer</strong> &#8211; some digging through headers seems to indicate this is <a href="http://www.sonivoxrocks.com/jet.html">Sonivox JET</a>, which looks like a MIDI engine. It also promises to ease development of rhythm games. Not a lot of details on this yet, but expect to see a glut of drum sequencers, pianos, Tap Tap Revolution ripoffs, and MIDI editors popping up on the Market once the documentation is fleshed out a bit.</li>
<li><strong>SoundPool fixes</strong> &#8211; my initial testing shows that they&#8217;ve fixed some of the bugs with the low-latency SoundPool audio APIs. In API 1.1, calling the stop() method for an audio stream instantly crashed your app. This led to delays in audio as multiple streams had to be muted and allowed to die, and wasted developer time writing code to do audio stream bookkeeping. Now, it just works! Expect better sound from games and more features from apps like RockOut as a result.</li>
<li><strong>XML File Wizard </strong>- I&#8217;m generally a <a class="zem_slink" title="TextMate" rel="homepage" href="http://www.macromates.com/">TextMate</a> / Vim kind of guy, but there&#8217;s a lot of hard-to-remember options to deal with when creating views for an Android app, and fine-grained targeting will get really scary when more hardware comes out with a wide variety of capabilities. A relatively simple way to say &#8220;use this template when they&#8217;re on a portrait touchscreen device and this one on a landscape device with a trackball&#8221; is going to be really helpful, and it should eliminate some programmer confusion.</li>
</ul>
<h3>Five Nice Touches</h3>
<p>Details matter. These don&#8217;t necessarily make for bragging rights but they all improve the user experience in some way.</p>
<div class="alignleft">
<a href="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-carbon-fiber.jpg"><img src="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-carbon-fiber-150x150.jpg" alt="cupcake-carbon-fiber" title="cupcake-carbon-fiber" width="150" height="150" class="alignleft size-thumbnail wp-image-176" /></a><br />
<hr /><a href="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-bookmarks.gif"><img src="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-bookmarks-150x150.gif" alt="cupcake-bookmarks" title="cupcake-bookmarks" width="150" height="150" class="alignleft size-thumbnail wp-image-175" /></a><br />
<hr /><a href="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-starred-contacts.gif"><img src="http://media.activefrequency.com/wp-uploads/2009/04/cupcake-starred-contacts-150x150.gif" alt="cupcake-starred-contacts" title="cupcake-starred-contacts" width="150" height="150" class="alignleft size-thumbnail wp-image-180" /></a>
</div>
<ul>
<li> <strong>Carbon-Fiber </strong>Applications List &#8211; Like a racing bike&#8217;s frame, this obviously makes it go faster. But in all seriousness, the semi-transparent apps list in 1.0/1.1 were hard to read at times, and this helps.</li>
<li> <strong>Animated Transitions </strong>- Subtle, and most importantly, fast (a fraction of a second) so it adds to the experience rather than just slowing me down.</li>
<li> <strong>Better Bookmarks</strong>/Most Visited/History View  &#8211; History view used to be buried as a menu option. This makes it much easier to manage my favorites without having to dig through menus.</li>
<li> <strong>SquirrelFish</strong> &#8211; <a class="zem_slink" title="WebKit" rel="homepage" href="http://webkit.org/">WebKit</a>&#8217;s new Javscript engine should make things faster. A lot faster, for Javascript-heavy Web apps. It&#8217;s not a visible change, but it&#8217;s significant. By most measures, at least on desktops, it&#8217;s up to <a href="http://paste.lisp.org/display/61070">4x faster</a> than the old WebKit engine. It&#8217;s not as fast as V8, the engine Google uses in Chrome, but it should be a nice little bump in responsiveness for Web applications and Android apps with embedded WebViews, like the Gmail app.</li>
<li> <strong>Pictures in Starred Contacts</strong> view &#8211; Rather than a generic star icon. Looks nice, and it&#8217;s helpful for me to find who I&#8217;m looking for within a list of favorites since there&#8217;s no particular order to them.</li>
</ul>
<p>Did I miss your favorite new feature? Weigh in with a comment below the entry.</p>
<p>(The title of this post is a nod to our delicious neighbors and <a href="http://online.wsj.com/article/SB123992364819927171.html">Comic Sans MS</a> abusers, <a href="http://www.kickasscupcakes.com/">Kickass Cupcakes</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/15-new-kick-ass-android-cupcake-features/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Changing Android DRM Breaks Apps</title>
		<link>http://activefrequency.com/blog/2009/changing-android-drm-breaks-apps/</link>
		<comments>http://activefrequency.com/blog/2009/changing-android-drm-breaks-apps/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 19:22:15 +0000</pubDate>
		<dc:creator>Yoni Samlan</dc:creator>
				<category><![CDATA[RockOut]]></category>
		<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://activefrequency.com/blog/?p=162</guid>
		<description><![CDATA[**UPDATE (4/20/2009) &#8211; a Google employee has commented on the open bug report and says this will be fixed in a future software release. Whether this makes it into the impending Cupcake update is anyone&#8217;s guess, though.**
Today we released the 1.1 update to RockOut Acoustic Pro. This update adds some neat new features like &#8220;Fretting [...]]]></description>
			<content:encoded><![CDATA[<p>**UPDATE (4/20/2009) &#8211; a Google employee has commented on the <a href="http://code.google.com/p/android/issues/detail?id=2047">open bug report</a> and says this will be fixed in a future software release. Whether this makes it into the impending Cupcake update is anyone&#8217;s guess, though.**</p>
<p>Today we released the 1.1 update to RockOut Acoustic Pro. This update adds some neat new features like &#8220;Fretting Mode,&#8221; which lets you hold the screen to &#8220;fret&#8221; chords and strum using the trackball. We thoroughly tested the application for both new installs and updates from the old version, on both the Android emulator and an actual G1. Everything looked good.</p>
<p>But when we actually put the update on the Market, some users complained the app was automatically <b>force closing</b> (read: crashing) when they installed the update.</p>
<p>I couldn&#8217;t reproduce it, but then a user sent me his log files (thanks to the wonderful Log Collector app). Here&#8217;s some relevant parts, and then the explanation:</p>
<p><code>E/PackageManager(   51): Package com.activefrequency.android.rockoutacousticpro has mismatched uid: 10046 on disk, 10047 in settings; read messages:<br />
...<br />
E/Database(  228): sqlite3_open_v2("/data/data/com.activefrequency.android.rockoutacousticpro/databases/song_list.db", &#038;handle, 6, NULL) failed<br />
...</code></p>
<p>Here&#8217;s why this happened: When we first released RockOut Acoustic Pro we had copy protection turned on. I turned it off a day or two later because an odd Market bug that Google won&#8217;t really acknowledge causes copy protected apps not to show at all on the market on many phones (normal G1s, not just ADPs).</p>
<p>This only happened, as far as I can tell, to users who previously had the copy protected version of my app installed.</p>
<p>The copy protection mechanism changes the uid of the application, so that non-copy-protected versions of the <b>same app</b> signed by the <b>same key</b> are no longer recognized as the same application, and are denied access to the database and other resources for the application.</p>
<p>This is <i>never</i> documented anywhere in any official Market or Android documentation, as far as I can see.</p>
<p>Plus, we had no way to figure this out on our own because developers can never install their own paid apps off the market, therefore can never test the copy-protected versions of their apps!</p>
<p>Now that I actually know the root cause of the problem, it&#8217;s easy enough to google and I can see I&#8217;m <a  href="http://www.google.com/search?q=openhome+update+copy+protection&#038;ie=UTF-8&#038;oe=UTF-8">not the first dev burned by it</a>.</p>
<p>There&#8217;s a <a href="http://code.google.com/p/android/issues/detail?id=2047">ticket to fix this</a> but no progress that I can see. This means Google is aware of the problem, yet <i>doesn&#8217;t tell you about it when they know you&#8217;re about to break updates for your app by checking or unchecking the copy protection box</i>. This is a 100% predictable result, and should be simple to warn developers about before they hurt their reputation or suddenly get dozens of negative reviews.</p>
<p>The absolute bare minimum Google can do is DOCUMENT this. I can&#8217;t see it taking more than 10 minutes to add a warning box when you add or remove copy protection from an app already live on the market, and it would have saved me a good hour of frantic hunting for a bug in my code that wasn&#8217;t there.</p>
<p>Is just <b>disclosing this</b> to developers too much to ask?</p>
]]></content:encoded>
			<wfw:commentRss>http://activefrequency.com/blog/2009/changing-android-drm-breaks-apps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
