<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CkQHSHY-cSp7ImA9WhFTFEk.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901</id><updated>2013-06-05T09:52:19.859-04:00</updated><category term="mobile" /><category term="Python" /><category term="Drawer" /><category term="support" /><category term="pager" /><category term="RB" /><category term="web" /><category term="2011" /><category term="Button" /><category term="development" /><category term="objective c" /><category term="hyper" /><category term="4.0" /><category term="Apple" /><category term="application" /><category term="Bloom" /><category term="RBRecorder" /><category term="Testing" /><category term="Computer" /><category term="practice" /><category term="minecraft" /><category term="iphone" /><category term="TDD" /><category term="guice" /><category term="frameworks" /><category term="Ice Cream Sandwich" /><category term="racquetball" /><category term="apps" /><category term="4.2" /><category term="Expirements" /><category term="link" /><category term="Honeycomb" /><category term="Ipad" /><category term="performance" /><category term="iOS" /><category term="Android" /><category term="robo. guice" /><category term="generator" /><category term="database" /><category term="ListView" /><category term="knowledge" /><category term="Compound" /><category term="starter" /><category term="patterns" /><category term="security" /><category term="programming" /><category term="hybrid" /><category term="creator" /><category term="tutorial" /><category term="experience" /><category term="goals" /><category term="software design" /><category term="communication" /><category term="Science" /><category term="Java" /><category term="viewer" /><category term="ball" /><category term="Google" /><category term="networking" /><category term="page" /><category term="Set" /><category term="Sliding" /><category term="Filter" /><category term="I/O" /><category term="data structures" /><category term="opinion" /><category term="view" /><category term="Eclipse" /><category term="Distributed Platforms" /><category term="third party" /><category term="Widget" /><category term="quality" /><category term="EditText" /><category term="Tablet" /><category term="racquet" /><category term="architecture" /><category term="Android TextView" /><category term="blogging" /><category term="UI Design" /><title>Programming Mobile</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.programmingmobile.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>63</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/programmingmobile/sKjg" /><feedburner:info uri="programmingmobile/skjg" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CkQHSHY8fyp7ImA9WhFTFEk.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-2911659350980607926</id><published>2013-06-05T09:50:00.002-04:00</published><updated>2013-06-05T09:52:19.877-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-06-05T09:52:19.877-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="patterns" /><category scheme="http://www.blogger.com/atom/ns#" term="software design" /><category scheme="http://www.blogger.com/atom/ns#" term="architecture" /><title>Design Patterns - Abstract Factory</title><content type="html">&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Design Pattern Review&lt;/span&gt;&lt;/div&gt;
&lt;b id="docs-internal-guid--9c156d8-1498-22a4-2ea5-e7f2fe779018" style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Need a refresher on Design Patterns? There are plenty of Design Patterns out there. Over the next few months, I plan on writing a bit about most of the common design patterns that can make your life (and mine) as a developer much easier. My aim is to give you just enough of the idea to then be able to research the details from some other resources (some of which I have included).&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;To start off, I’ll be going through a bunch of Creational Patterns, patterns that are useful when you need to create objects.&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Creational Patterns&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;To start off, let’s talk about the Abstract Factory pattern. The Abstract Factory pattern enables the creation of a set of common objects without having to know the concrete classes themselves.&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Abstract Factory&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;In Java term&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;s, &lt;/span&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt; usua&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;lly boils down to an abstract class. It is used to create a specific interface that all Factories will agree to. By agreeing to an interface up front, any class that uses one of these Factories doesn't need to know anything about what type of Factory it is really talking to.&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;What It Can Do for You&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;From the cod&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;e, &lt;/span&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt; all&lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;ows you the ability to swap out Factory types with a single line change. All that is needed is to change the Abstract pointer’s concrete Factory instance. Nothing else needs to be changed.&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;What It Can’t Do for You&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;There are a few drawbacks wit&lt;/span&gt;&lt;span style="background-color: white;"&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;h &lt;/span&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;this&lt;/span&gt;&lt;span style="color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;design. If you find yourself having to add new types (via new methods) to the Abstract Factory class, you will have to add this same method to all concrete &lt;/span&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Factory classes as well. This effectively means that all Factories must be modified when any additions are needed.&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Resources&lt;/span&gt;&lt;/div&gt;
&lt;b style="font-weight: normal;"&gt;&lt;br /&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;For more information, including examples, check out these resources:&lt;/span&gt;&lt;/div&gt;
&lt;ul style="margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;"&gt;&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Wikipedia: &lt;/span&gt;&lt;a href="http://en.wikipedia.org/wiki/Abstract_factory_pattern" style="text-decoration: none;"&gt;&lt;span style="background-color: transparent; color: #1155cc; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"&gt;http://en.wikipedia.org/wiki/Abstract_factory_pattern&lt;/span&gt;&lt;/a&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;"&gt;&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;The classic Design Patterns book: &lt;/span&gt;&lt;span style="white-space: pre-wrap;"&gt;&lt;a href="http://www.amazon.com/Design-Patterns-Elements-Object-Oriented-ebook/dp/B000SEIBB8/ref=sr_1_1?ie=UTF8&amp;amp;qid=1370440168&amp;amp;sr=8-1&amp;amp;keywords=Design+Patterns%3A+Elements+of+Reusable+Object-Oriented+Software" target="_blank"&gt;Design Patterns: Elements of Reusable Object-Oriented Software&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir="ltr" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;"&gt;&lt;div dir="ltr" style="line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;"&gt;
&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt;Why use a Abstract Factory? &lt;/span&gt;&lt;a href="http://stackoverflow.com/questions/2280170/why-do-we-need-abstract-factory-design-pattern" style="text-decoration: none;"&gt;&lt;span style="background-color: transparent; color: #1155cc; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;"&gt;http://stackoverflow.com/questions/2280170/why-do-we-need-abstract-factory-design-pattern&lt;/span&gt;&lt;/a&gt;&lt;span style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;span style="font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;/span&gt;&lt;span style="font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;"&gt;Next - The Factory Method&lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/9xjxvMTFwqc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/2911659350980607926/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2013/06/design-patterns-abstract-factory.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/2911659350980607926?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/2911659350980607926?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/9xjxvMTFwqc/design-patterns-abstract-factory.html" title="Design Patterns - Abstract Factory" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2013/06/design-patterns-abstract-factory.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUICSXo6eCp7ImA9WhBWFU8.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-292823762536520242</id><published>2013-04-09T13:07:00.001-04:00</published><updated>2013-04-09T13:12:48.410-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-09T13:12:48.410-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="frameworks" /><category scheme="http://www.blogger.com/atom/ns#" term="pager" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="Sliding" /><category scheme="http://www.blogger.com/atom/ns#" term="software design" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="viewer" /><category scheme="http://www.blogger.com/atom/ns#" term="page" /><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="apps" /><category scheme="http://www.blogger.com/atom/ns#" term="architecture" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="4.0" /><category scheme="http://www.blogger.com/atom/ns#" term="view" /><title>Android Tutorial: Using the ViewPager</title><content type="html">&lt;p&gt;Currently, one of the most popular Widgets in the Android library is the ViewPager.  It's implemented in several of the most-used Android apps, like the Google Play app and one of my own apps, &lt;a href="https://play.google.com/store/apps/details?id=com.itaylor.rbrecorder&amp;amp;hl=en"&gt;RBRecorder&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img style="float: left;" title="google play 3.png" src="http://lh6.ggpht.com/-aL8ogPVDl2g/UWRKudcYcXI/AAAAAAAAHY4/LS-DE8407r4/google%252520play%2525203.png?imgmax=800" border="0" alt="RBRecorder" width="180" height="300" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;img style="float: right;" title="GooglePlay.jpg" src="http://lh3.ggpht.com/-eYVzgrTV7S4/UWRMDrlMEoI/AAAAAAAAHZI/nB2rcx6Yhag/GooglePlay.jpg?imgmax=800" border="0" alt="GooglePlay" width="355" height="200" /&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;The &lt;a href="http://developer.android.com/reference/android/support/v4/view/ViewPager.html"&gt;ViewPager&lt;/a&gt; is the widget that allows the user to swipe left or right to see an entirely new screen. In a sense, it's just a nicer way to show the user multiple tabs. It also has the ability to dynamically add and remove pages (or tabs) at anytime. Consider the idea of grouping search results by certain categories, and showing each category in a separate list. With the ViewPager, the user could then swipe left or right to see other categorized lists. Using the ViewPager requires some knowledge of both Fragments and PageAdapters. In this case, Fragments are "pages". Each screen that the ViewPager allows the user to scroll to is really a Fragment. By using Fragments instead of a View here, we're given a much wider range of possibilities to show in each page. We're not limited to just a List of items. This could be any collection of views and widgets we may need. You can think of PageAdapters in the same way that you think of ListAdapters. The Page Adapter's job is to supply Fragments (instead of views) to the UI for drawing.&lt;/p&gt;
&lt;p&gt;I've put together a quick tutorial that gets a ViewPager up and running (with the Support Library), in just a few steps. This tutorial follows more of a top-down approach. It moves from the Application down to the Fragments. If you want to dive straight into the source code yourself, you can grab the project &lt;a href="https://github.com/ProMobile/ViewPagerTutorial"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;At The Application Level&lt;/h3&gt;
&lt;p&gt;Before getting started, it's important to make sure the Support Library is updated from your SDK, and that the library itself is included in your project. Although the ViewPager and Fragments are newer constructs in Android, it's easy to port them back to older versions of Android by using the Support Library. To add the library to your project, you'll need to create a "libs" folder in your project and drop the JAR file in. For more information on this step, check out this page on the &lt;a href="http://developer.android.com/tools/extras/support-library.html"&gt;Support Library help page&lt;/a&gt; on the developer site.&lt;/p&gt;
&lt;h3&gt;Setting Up The Layout File&lt;/h3&gt;
&lt;p&gt;The next step is to add the ViewPager to your layout file for your Activity. This step requires you to dive into the XML of your layout file instead of using the GUI layout editor. Your layout file should look something like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3b3ffb;"&gt;&lt;span style="color: #019192;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #509091;"&gt;RelativeLayout&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #922790;"&gt;xmlns:android&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;"http://schemas.android.com/apk/res/android"&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3b3ffb;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #922790;"&gt;xmlns:tools&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;"http://schemas.android.com/tools"&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;android:layout_width&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"match_parent"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;android:layout_height&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"match_parent"&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #019192;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #019192;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #509091;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #019192;"&gt;  &amp;lt;&lt;/span&gt;android.support.v4.view.ViewPager&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3b3ffb;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #922790;"&gt;    android:id&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;"@+id/viewpager"&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;    android:layout_width&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"fill_parent"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;    android:layout_height&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"fill_parent"&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #019192;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #019192;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #509091;"&gt;&lt;span style="color: #019192;"&gt;&amp;lt;/&lt;/span&gt;RelativeLayout&lt;span style="color: #019192;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Implementing The Activity&lt;/h3&gt;
&lt;p&gt;Now we'll put the main Activity together. The main takeaways from this activity are as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The class inherits from &lt;a href="http://developer.android.com/reference/android/support/v4/app/FragmentActivity.html"&gt;FragmentActivity&lt;/a&gt;, not &lt;a href="http://developer.android.com/reference/android/app/Activity.html"&gt;Activity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;This Activity "has a" &lt;a href="http://developer.android.com/reference/android/support/v4/view/PagerAdapter.html"&gt;PageAdapter&lt;/a&gt; object and a Fragment object, which we will define a bit later&lt;/li&gt;
&lt;li&gt;The Activity needs to initialize it's own PageAdapter&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;public&lt;/span&gt; &lt;span style="color: #921f67;"&gt;class&lt;/span&gt; PageViewActivity &lt;span style="color: #921f67;"&gt;extends&lt;/span&gt; FragmentActivity {&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;  &lt;/span&gt;MyPageAdapter &lt;span style="color: #0a30c8;"&gt;pageAdapter&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #777777;"&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;@Override&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #777777;"&gt;&lt;span style="color: #000000;"&gt;&lt;span style="color: #921f67;"&gt;  public&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #000000;"&gt;&lt;span style="color: #921f67;"&gt;void&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #000000;"&gt; onCreate(Bundle savedInstanceState) {&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;    super&lt;/span&gt;.onCreate(savedInstanceState);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;    setContentView(R.layout.&lt;span style="color: #0a30c8;"&gt;activity_page_view&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;    List&amp;lt;Fragment&amp;gt; fragments = getFragments();&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #0a30c8;"&gt;    pageAdapter&lt;/span&gt; = &lt;span style="color: #921f67;"&gt;new&lt;/span&gt; MyPageAdapter(getSupportFragmentManager(), fragments);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;    ViewPager pager = (ViewPager)findViewById(R.id.&lt;span style="color: #0a30c8;"&gt;viewpager&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;    pager.setAdapter(&lt;span style="color: #0a30c8;"&gt;pageAdapter&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;  }&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="font-family: Helvetica; white-space: normal; font-size: medium;"&gt;}&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Implementing The PageAdapter&lt;/h3&gt;
&lt;p&gt;Now that we have the FragmentActivity covered, we need to create our PageAdapter. This is a class that inherits from the FragmentPageAdapater class. In creating this class, we have two goals in mind:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Make sure the Adapter has our fragment list&lt;/li&gt;
&lt;li&gt;Make sure it gives the Activity the correct fragment&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;class&lt;/span&gt; MyPageAdapter &lt;span style="color: #921f67;"&gt;extends&lt;/span&gt; FragmentPagerAdapter {&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #921f67;"&gt;private&lt;/span&gt; List&amp;lt;Fragment&amp;gt; &lt;span style="color: #0a30c8;"&gt;fragments&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;  public&lt;/span&gt; MyPageAdapter(FragmentManager fm, List&amp;lt;Fragment&amp;gt; fragments) {&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;    super&lt;/span&gt;(fm);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;    this&lt;/span&gt;.&lt;span style="color: #0a30c8;"&gt;fragments&lt;/span&gt; = fragments;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;  }&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #777777;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt; @Override &lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;  public&lt;/span&gt; Fragment getItem(&lt;span style="color: #921f67;"&gt;int&lt;/span&gt; position) {&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;    return&lt;/span&gt; &lt;span style="color: #921f67;"&gt;this&lt;/span&gt;.&lt;span style="color: #0a30c8;"&gt;fragments&lt;/span&gt;.get(position);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;  }&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #777777;"&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt; @Override&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;  public&lt;/span&gt; &lt;span style="color: #921f67;"&gt;int&lt;/span&gt; getCount() {&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;    return&lt;/span&gt; &lt;span style="color: #921f67;"&gt;this&lt;/span&gt;.&lt;span style="color: #0a30c8;"&gt;fragments&lt;/span&gt;.size();&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;  }&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;h3&gt;Getting The Fragments Set Up&lt;/h3&gt;
&lt;p&gt;With the PageAdapter complete, all that is now needed are the Fragments themselves. We need to implement two things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The getFragment method in the PageViewActivity&lt;/li&gt;
&lt;li&gt;The MyFragment class&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;1. The getFragment method is straightforward. The only question is how are the actual Fragments created. For now, we'll leave that logic to the MyFragment class.&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;private&lt;/span&gt; List&amp;lt;Fragment&amp;gt; getFragments(){&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;  &lt;/span&gt;List&amp;lt;Fragment&amp;gt; fList = &lt;span style="color: #921f67;"&gt;new&lt;/span&gt; ArrayList&amp;lt;Fragment&amp;gt;();&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;  &lt;/span&gt;fList.add(MyFragment.newInstance(&lt;span style="color: #3b3ffb;"&gt;"Fragment 1"&lt;/span&gt;));&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;  &lt;/span&gt;fList.add(MyFragment.newInstance(&lt;span style="color: #3b3ffb;"&gt;"Fragment 2"&lt;/span&gt;)); &lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;  &lt;/span&gt;fList.add(MyFragment.newInstance(&lt;span style="color: #3b3ffb;"&gt;"Fragment 3"&lt;/span&gt;));&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;  &lt;/span&gt;&lt;span style="color: #921f67;"&gt;return&lt;/span&gt; fList;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;2. The MyFragment class also has it's own layout file. For this example, the layout file only consists of a simple TextView. We'll use this TextView to tell us which Fragment we are currently looking at (notice in the getFragments code, we are passing in a String in the newInstance method).&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #019192;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #509091;"&gt;xml&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;version&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"1.0"&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;encoding&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"utf-8"&lt;/span&gt;&lt;span style="color: #019192;"&gt;?&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3b3ffb;"&gt;&lt;span style="color: #019192;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #509091;"&gt;RelativeLayout&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #922790;"&gt;xmlns:android&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;"http://schemas.android.com/apk/res/android"&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;android:layout_width&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"match_parent"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;android:layout_height&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"match_parent"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;android:orientation&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"vertical"&lt;/span&gt;&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #019192;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #509091;"&gt;&lt;span style="color: #000000;"&gt;  &lt;/span&gt;&lt;span style="color: #019192;"&gt;&amp;lt;&lt;/span&gt;TextView&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3b3ffb;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #922790;"&gt;android:id&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;"@+id/textView"&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;android:layout_width&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"wrap_content"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;android:layout_height&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"wrap_content"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;android:layout_centerHorizontal&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"true"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #922790;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;android:layout_centerVertical&lt;span style="color: #000000;"&gt;=&lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"true"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #3b3ffb;"&gt;&lt;span style="color: #000000;"&gt;    &lt;/span&gt;&lt;span style="color: #922790;"&gt;android:textAppearance&lt;/span&gt;&lt;span style="color: #000000;"&gt;=&lt;/span&gt;"?android:attr/textAppearanceLarge"&lt;span style="color: #000000;"&gt; &lt;/span&gt;&lt;span style="color: #019192;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;br /&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #509091;"&gt;&lt;span style="color: #019192;"&gt;&amp;lt;/&lt;/span&gt;RelativeLayout&lt;span style="color: #019192;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;And now the Fragment code itself: The only trick here is that we create the fragment using a static class method, and we use a Bundle to pass information to the Fragment object itself.&lt;/p&gt;
&lt;blockquote&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;public&lt;/span&gt; &lt;span style="color: #921f67;"&gt;class&lt;/span&gt; MyFragment &lt;span style="color: #921f67;"&gt;extends&lt;/span&gt; Fragment {&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #921f67;"&gt;&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;public&lt;span style="color: #000000;"&gt; &lt;/span&gt;static&lt;span style="color: #000000;"&gt; &lt;/span&gt;final&lt;span style="color: #000000;"&gt; String &lt;/span&gt;&lt;span style="color: #0a30c8;"&gt;EXTRA_MESSAGE&lt;/span&gt;&lt;span style="color: #000000;"&gt; = &lt;/span&gt;&lt;span style="color: #3b3ffb;"&gt;"EXTRA_MESSAGE"&lt;/span&gt;&lt;span style="color: #000000;"&gt;;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;span style="color: #921f67;"&gt;public&lt;/span&gt; &lt;span style="color: #921f67;"&gt;static&lt;/span&gt; &lt;span style="color: #921f67;"&gt;final&lt;/span&gt; MyFragment newInstance(String message)&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;{&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;   &lt;/span&gt;MyFragment f = &lt;span style="color: #921f67;"&gt;new&lt;/span&gt; MyFragment();&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;   &lt;/span&gt;Bundle bdl = &lt;span style="color: #921f67;"&gt;new&lt;/span&gt; Bundle(1);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;  bdl.putString(&lt;span style="color: #0a30c8;"&gt;EXTRA_MESSAGE&lt;/span&gt;, message);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;  f.setArguments(bdl);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;  &lt;span style="color: #921f67;"&gt;return&lt;/span&gt; f;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #777777;"&gt;&lt;span style="color: #000000;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/span&gt;@Override&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt; public&lt;/span&gt; View onCreateView(LayoutInflater inflater, ViewGroup container,&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;   Bundle savedInstanceState) {&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;   &lt;/span&gt;String message = getArguments().getString(&lt;span style="color: #0a30c8;"&gt;EXTRA_MESSAGE&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;   &lt;/span&gt;View v = inflater.inflate(R.layout.&lt;span style="color: #0a30c8;"&gt;myfragment_layout&lt;/span&gt;, container, &lt;span style="color: #921f67;"&gt;false&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;   &lt;/span&gt;TextView messageTextView = (TextView)v.findViewById(R.id.&lt;span style="color: #0a30c8;"&gt;textView&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="white-space: pre;"&gt;   &lt;/span&gt;messageTextView.setText(message);&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; min-height: 15.0px;"&gt;&lt;span style="white-space: pre;"&gt; &lt;/span&gt;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;&lt;span style="color: #921f67;"&gt;   return&lt;/span&gt; v;&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt; }&lt;/pre&gt;
&lt;pre style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco;"&gt;}&lt;/pre&gt;
&lt;/blockquote&gt;
&lt;p&gt;That's it! with the above code, you can easily get a simple page adapter up and running. You can also get the &lt;a href="https://github.com/ProMobile/ViewPagerTutorial"&gt;source code&lt;/a&gt; of the above tutorial from &lt;a href="https://github.com/ProMobile/ViewPagerTutorial"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;For More Advance Developers&lt;/h3&gt;
&lt;p&gt;There are actually a few different types of FragmentPageAdapters out there. It is important to know what they are and what they do, as knowing this bit of information could save you some time when creating complex applications with the ViewPager. The &lt;a href="http://developer.android.com/reference/android/support/v4/app/FragmentPagerAdapter.html"&gt;FragmentPagerAdapter&lt;/a&gt; is the more general PageAdapter to use. This version does not destroy Fragments it has as long as the user can potentially go back to that Fragment. The idea is that this PageAdapter is used for mainly "static" or unchanging Fragments. If you have Fragments that are more dynamic and change frequently, you may want to look into the &lt;a href="http://developer.android.com/reference/android/support/v4/app/FragmentStatePagerAdapter.html"&gt;FragmentStatePagerAdapter&lt;/a&gt;. This Adapter is a bit more friendly to dynamic Fragments and doesn't consume nearly as much memory as the FragmentPagerAdapter.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/oW8HLkaG3fI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/292823762536520242/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2013/04/android-tutorial-using-viewpager.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/292823762536520242?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/292823762536520242?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/oW8HLkaG3fI/android-tutorial-using-viewpager.html" title="Android Tutorial: Using the ViewPager" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-aL8ogPVDl2g/UWRKudcYcXI/AAAAAAAAHY4/LS-DE8407r4/s72-c/google%252520play%2525203.png?imgmax=800" height="72" width="72" /><thr:total>2</thr:total><feedburner:origLink>http://www.programmingmobile.com/2013/04/android-tutorial-using-viewpager.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcHQXk_cCp7ImA9WhBRFE4.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-3576968630280824599</id><published>2013-03-04T17:27:00.001-05:00</published><updated>2013-03-04T17:27:10.748-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-04T17:27:10.748-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="4.2" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="security" /><category scheme="http://www.blogger.com/atom/ns#" term="Google" /><title>Reading Logs Disabled in Jelly Bean</title><content type="html">&lt;p&gt;Just a heads up for anyone looking to read the standard ADB logs directly within your application. From Jelly Bean and up, you won't be able to access them on a non-rooted device. Although you can still ask for the permission via the &lt;a href="http://developer.android.com/reference/android/Manifest.permission.html#READ_LOGS"&gt;READ_LOGS&lt;/a&gt; tag, you won't be granted the permission.&lt;/p&gt;
&lt;p&gt;For more information check out these links:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/questions/11461650/read-logs-permission-on-jelly-bean-api-16"&gt;StackOverflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://groups.google.com/forum/?fromgroups=#!topic/android-developers/6U4A5irWang"&gt;Google Groups&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/8Fk8FBEjmm8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/3576968630280824599/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2013/03/reading-logs-disabled-in-jelly-bean.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3576968630280824599?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3576968630280824599?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/8Fk8FBEjmm8/reading-logs-disabled-in-jelly-bean.html" title="Reading Logs Disabled in Jelly Bean" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2013/03/reading-logs-disabled-in-jelly-bean.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcMSXY_eSp7ImA9WhBTGEo.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-1399727262238585257</id><published>2013-02-14T16:41:00.001-05:00</published><updated>2013-02-14T16:41:28.841-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-14T16:41:28.841-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="frameworks" /><category scheme="http://www.blogger.com/atom/ns#" term="data structures" /><category scheme="http://www.blogger.com/atom/ns#" term="I/O" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="Eclipse" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="architecture" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="Google" /><category scheme="http://www.blogger.com/atom/ns#" term="database" /><title>Memory Management For Android Apps (Google IO)</title><content type="html">&lt;p&gt;&lt;span style="font-size: 14px;"&gt;In gearing up for this year's Google IO, I started looking over all of the sessions from the last few years to see what kind of gems are hidden there. I recently watched the latest &lt;/span&gt;&lt;span style="font-size: 14px;"&gt;&lt;a href="http://www.youtube.com/watch?v=_CruQY55HOk"&gt;Google IO session on Memory Management within Android&lt;/a&gt;&lt;/span&gt;&lt;span style="font-size: 14px;"&gt;. While I watched the video, I took some notes of what I thought were the more important and interesting points. At a high level, the video has some interesting info about how memory is allocated in Android (and really, Java itself).&lt;/span&gt;&lt;/p&gt;
&lt;p style="font-size: 13px;"&gt;&lt;span style="font-family: Helvetica; font-size: 13px;"&gt;&lt;span id="internal-source-marker_0.5238037323579192" style="color: #000000; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span style="color: #000000; background-color: transparent; font-style: normal; font-variant: normal; text-decoration: initial; vertical-align: baseline; white-space: pre-wrap;"&gt;&lt;a href="http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)"&gt;Garbage Collection&lt;/a&gt; (GC) is the process of reclaiming old memory in your application. Or in other words, taking objects that are no longer in use and freeing the memory used by them so the memory can be used for new objects.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 14px;"&gt;&lt;span style="white-space: pre-wrap;"&gt;The most interesting points in the video were about the Android Heap. The Heap is where all applications are stored within Android. Each Android app has a limit that is specific to each device. To find that limit, use the method &lt;/span&gt;&lt;span style="white-space: pre-wrap;"&gt;&lt;strong id="internal-source-marker_0.5238037323579192" style="color: #000000; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; font-weight: normal;"&gt;&lt;span style="color: #000000; background-color: transparent; font-weight: normal; font-style: normal; font-variant: normal; text-decoration: initial; vertical-align: baseline; white-space: pre-wrap;"&gt;ActivityMonitor,getMemoryClass.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 14px;"&gt;&lt;span style="white-space: pre-wrap;"&gt;&lt;strong id="internal-source-marker_0.5238037323579192" style="color: #000000; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; font-weight: normal;"&gt;&lt;span style="color: #000000; background-color: transparent; font-weight: normal; font-style: normal; font-variant: normal; text-decoration: initial; vertical-align: baseline; white-space: pre-wrap;"&gt;Sometimes that Heap size isn't enough. Luckily, there is a way to increase the Heap size for your app. To increase the size, add the tag bigHeap to your Application tag in the manifest file. However, increasing the Heap&lt;strong id="internal-source-marker_0.5238037323579192" style="color: #000000; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; font-weight: normal;"&gt;&lt;span style="color: #000000; background-color: transparent; font-weight: normal; font-style: normal; font-variant: normal; text-decoration: initial; vertical-align: baseline; white-space: pre-wrap;"&gt; can be a double-edged sword. By having a large Heap, GC can take considerably longer because GC has to go through a larger Heap to check for objects that can be freed. So just using this tag to get away from memory leaks in your app is a pretty bad idea and will only make your app performance decrease.&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 14px;"&gt;This video also goes into memory leaks. To start off, a memory leak&lt;strong id="internal-source-marker_0.5238037323579192" style="color: #000000; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; font-weight: normal;"&gt;&lt;span style="color: #000000; background-color: transparent; font-weight: normal; font-style: normal; font-variant: normal; text-decoration: initial; vertical-align: baseline; white-space: pre-wrap;"&gt; means you still have a reference to an unused object, which means GC can't remove an object. One common memory leak in Android involves keeping a reference to an Activity(or a context) for far too long. This is especially common when handling Activity rotation changes. &lt;/span&gt;&lt;/strong&gt;Finding and fixing memory leaks is more of a dark art of software development. It's a very important skill to have in your pocket simply because the Garbage Collector won't save your memory in all cases. For example, if you happen to pass Context objects around frequently in your application, it's much more likely that a memory leak has crept into your app. By using the &lt;a href="http://www.eclipse.org/mat/"&gt;Eclipse Memory Analyzer&lt;/a&gt;, it's pretty simple to find a leak using a few tricks that are shown in the video (like using &lt;a href="http://en.wikipedia.org/wiki/Dominator_(graph_theory)"&gt;Dominator Trees&lt;/a&gt;) and to do a few changes to your code to fix it.&lt;/span&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/cIoeNcjsRUM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/1399727262238585257/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2013/02/memory-management-for-android-apps.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/1399727262238585257?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/1399727262238585257?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/cIoeNcjsRUM/memory-management-for-android-apps.html" title="Memory Management For Android Apps (Google IO)" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2013/02/memory-management-for-android-apps.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YERnYyfSp7ImA9WhBTEEw.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-1288676865623449205</id><published>2013-02-04T16:58:00.000-05:00</published><updated>2013-02-04T16:58:27.895-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-04T16:58:27.895-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="application" /><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="knowledge" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="Ice Cream Sandwich" /><title>Hardware Acceleration in Android - Are You Using It?</title><content type="html">&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;Did you know Android has Hardware Acceleration? Did you also know you actually need to enable it for your app first? Suprisingly you do! It's not defaulted to on. Here's another little gem in Android that could have a major impact on your application.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;If you allow your app to run on Android versions above 3.0, you should probably enable Hardware Acceleration. By enabling Hardware Acceleration, the performance of your application's UI may improve considerably. To enable Hardware Acceleration on an application, simply add the&amp;nbsp;&lt;code style="background-color: #f9f9f9; color: #006600; font-family: 'courier new', courier, monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: bold; letter-spacing: normal; line-height: 1.5; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;android:hardwareAccelerated&lt;/code&gt;&lt;code style="background-color: #f9f9f9; color: #006600; font-family: 'courier new', courier, monospace; font-size: 14px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 1.5; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;"&gt;&lt;span style="color: #222222; font-family: Roboto, sans-serif;"&gt;&lt;strong style="font-weight: bold;"&gt;&amp;nbsp;&lt;/strong&gt;&lt;/span&gt;&lt;/code&gt;&lt;span style="color: #006600; line-height: 21px; white-space: pre;"&gt;&lt;span style="color: black; line-height: normal; white-space: normal;"&gt;tag to the &lt;/span&gt;&lt;span style="color: black; line-height: normal; white-space: normal;"&gt;&lt;a href="http://developer.android.com/guide/topics/manifest/application-element.html"&gt;manifest file&lt;/a&gt;&lt;/span&gt;&lt;span style="color: black; line-height: normal; white-space: normal;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;&lt;span style="color: #006600; line-height: 21px; white-space: pre;"&gt;&lt;span style="color: black; line-height: normal; white-space: normal;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;After adding that tag to the application element, simply recompile and test your app. It is very important to fully test your app after you add this line. Although it's unlikely that Hardware Acceleration will negatively affect your app, it is certainly possible. It is a good idea to make sure all of the views and animations still work as you expect it to.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;If you find that certain screens seem to have problems with Hardware Acceleration, you can disable it on a per Activity basis if needed as well. To do so, simply add the tag (set to false) to the activity tag within the manifest. This allows you to enable Hardware Acceleration for the entire application while removing it for certain parts. And this also works in the reverse. You can enable only specific Activities while leaving it off for the majority of the application.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;One other interesting feature in the IO Session (linked below) is the concept of a View Layer. By using this new Layer method, you are able to use the GPU within the device to speed up animations (IE ListView scrolling). Check out &lt;a href="http://developer.android.com/reference/android/view/View.html#attr_android:layerType"&gt;View.setLayerType&lt;/a&gt; for some more information.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Helvetica; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="font-size: 12px;"&gt;&lt;span style="font-size: 12px;"&gt;&lt;span style="font-size: 12px;"&gt;&lt;span style="font-family: Helvetica;"&gt;&lt;span style="font-size: 12px;"&gt;For more details about Hardware Acceleration--and really some interesting information on how views are actually drawn in Android--check out this &lt;a href="http://www.youtube.com/watch?v=v9S5EO7CLjo"&gt;Google IO Session&lt;/a&gt;. And like most things Android-related, Google has a detailed page&amp;nbsp;&lt;a href="http://developer.android.com/guide/topics/graphics/hardware-accel.html"&gt;here&lt;/a&gt; on Hardware Acceleration.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/STRZTT7HZ54" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/1288676865623449205/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2013/02/hardware-acceleration-in-android-are.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/1288676865623449205?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/1288676865623449205?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/STRZTT7HZ54/hardware-acceleration-in-android-are.html" title="Hardware Acceleration in Android - Are You Using It?" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2013/02/hardware-acceleration-in-android-are.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcDRnwzfip7ImA9WhNbGE0.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-2490398917042934036</id><published>2013-01-21T16:01:00.000-05:00</published><updated>2013-01-21T16:01:17.286-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-21T16:01:17.286-05:00</app:edited><title>Android Library: Drag to Sort and Swipe to Delete List View</title><content type="html">Here's a pretty nice custom list view that allows the user to sort the items in the list view by dragging rows up and down, or removing a row dynamically with a side swipe.&lt;br /&gt;
&lt;br /&gt;
The source can be found on Github &lt;a href="https://github.com/bauerca/drag-sort-listview" target="_blank"&gt;here&lt;/a&gt;. The list view runs very smoothly. Carl has also thrown up a simple demo app to show it off, too. Even if you don't need a list view with this type of functionality at the moment, it's a good custom widget to keep in mind for when you do need it.&lt;br /&gt;
&lt;br /&gt;
The repo is fairly active as well. If you have any suggestions or requests, now would be the time to get your comments up there.&lt;br /&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/qxBLqITYx_0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/2490398917042934036/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2013/01/android-library-drag-to-sort-and-swipe.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/2490398917042934036?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/2490398917042934036?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/qxBLqITYx_0/android-library-drag-to-sort-and-swipe.html" title="Android Library: Drag to Sort and Swipe to Delete List View" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2013/01/android-library-drag-to-sort-and-swipe.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMDQnc5cCp7ImA9WhNbEUQ.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-6840173695487755319</id><published>2013-01-13T15:57:00.001-05:00</published><updated>2013-01-14T16:04:33.928-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-01-14T16:04:33.928-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="application" /><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="support" /><category scheme="http://www.blogger.com/atom/ns#" term="knowledge" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="UI Design" /><category scheme="http://www.blogger.com/atom/ns#" term="software design" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="Ice Cream Sandwich" /><title>Loaders versus AsyncTask</title><content type="html">One of the biggest pieces of Android that I have neglected to learn about would be &lt;a href="http://developer.android.com/guide/components/loaders.html"&gt;Loaders&lt;/a&gt;. Seeing as it's time for me to learn it, perhaps I can help you out a bit with it as well. My main interest with the Loader concept is how it melds with the tried and true &lt;a href="http://developer.android.com/reference/android/os/AsyncTask.html"&gt;AsyncTask&lt;/a&gt;, and if it's really better or not.&lt;br /&gt;
&lt;h3&gt;
AsyncTask&lt;/h3&gt;
Before getting into the Loader concept, it's important to have a good idea of what the AsyncTask is and what it's used for within Android. If you have written any sort of application for Android, chances are you have played with the AsyncTask, or at the very least heard of it.&amp;nbsp;In Android, the AsyncTask class is one of the core development tools that most apps use. It gives the developer an easy way to do processing on a thread that isn't the UI thread. This keeps the UI thread focused on the UI instead of other time-intensive tasks, such as disk or server calls. There are a few issues with using AsyncTasks, though:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Configuration changes can mess things up&lt;/li&gt;
&lt;li&gt;Pausing an activity doesn't pause the AsyncTask&lt;/li&gt;
&lt;li&gt;A fair amount of boilerplate code (which means more possible errors)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
Loaders&lt;/h3&gt;
The AsyncTask isn't the only way to do background processing in Android, though. The Loader class is a much newer construct in Android (although now it's getting a bit dated). It was released with Honeycomb(3.0) and is now included in the &lt;a href="http://developer.android.com/tools/extras/support-library.html"&gt;Support Library&lt;/a&gt;.&amp;nbsp;The beauty of the Loader is that it handles some of the "gotchas" that usually are missed when using the AsyncTask. Mainly, it handles activity configuration changes (IE when the user rotates the screen).&lt;br /&gt;
Loaders (specifically the &lt;a href="http://developer.android.com/reference/android/content/CursorLoader.html"&gt;CursorLoader&lt;/a&gt;) really shine when using Cursors within Android to pull data. The Loader class does an excellent job of updating the Cursor information (and in turn, the UI) whenever the underlying data changes. This is immensely helpful when information changes often and you don't want to interrupt the UI, and whatever the user is currently doing, just to display some new information.&lt;br /&gt;
One particular subclass of Loaders is of interest: the &lt;a href="http://developer.android.com/reference/android/content/AsyncTaskLoader.html"&gt;AsyncTaskLoader&lt;/a&gt;. This class performs the same function as the AsyncTask, but a bit better. It can handle Activity configuration changes more easily, and it behaves within the life cycles of Fragments and Activities. The nice thing is that the AsyncTaskLoader can be used in any situation that the AsyncTask is being used. Anytime data needs to be loaded into memory for the Activity/Fragment to handle, The AsyncTaskLoader can do the job better.&lt;br /&gt;
To really get into the details of how to actually implement a AsyncTaskLoader, check out these sources:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Google has a pretty good example directly in the &lt;a href="http://developer.android.com/reference/android/content/AsyncTaskLoader.html"&gt;API Docs&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.androiddesignpatterns.com/2012/07/loaders-and-loadermanager-background.html"&gt;Android Design Patterns&lt;/a&gt; provides some more detail and the reasoning behind Loaders.&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/bDmhwH2Ps1g" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/6840173695487755319/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2013/01/loaders-versus-asynctask.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/6840173695487755319?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/6840173695487755319?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/bDmhwH2Ps1g/loaders-versus-asynctask.html" title="Loaders versus AsyncTask" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2013/01/loaders-versus-asynctask.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D04MRHg_eip7ImA9WhNWFks.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-3289413770866026589</id><published>2012-12-16T08:53:00.001-05:00</published><updated>2012-12-16T08:53:05.642-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-16T08:53:05.642-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="knowledge" /><category scheme="http://www.blogger.com/atom/ns#" term="UI Design" /><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="experience" /><title>Finding and Fixing Overdraw in Android</title><content type="html">&lt;p&gt;I just ran across an excellent &lt;a href="http://www.curious-creature.org/docs/android-performance-case-study-1.html"&gt;article&lt;/a&gt; about new performance analysis tools in Android (adding in 4.1), and how to improve list scrolling beyond the standard ViewHolder pattern (which may &lt;a href="http://drasticp.blogspot.com/2012/04/viewholder-is-dead.html"&gt;fade away&lt;/a&gt; soon) and other tweaks.&lt;/p&gt;
&lt;p&gt;Check it out here on &lt;a href="http://www.curious-creature.org/docs/android-performance-case-study-1.html"&gt;curious-creature&lt;/a&gt;! I plan on testing my applications for overdraw in the next few days. One step closer to really smooth lists.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/scwBsC3TYH0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/3289413770866026589/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/12/finding-and-fixing-overdraw-in-android.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3289413770866026589?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3289413770866026589?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/scwBsC3TYH0/finding-and-fixing-overdraw-in-android.html" title="Finding and Fixing Overdraw in Android" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/12/finding-and-fixing-overdraw-in-android.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4BR3wyeCp7ImA9WhNXFUo.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-5451451172859418804</id><published>2012-12-03T16:42:00.003-05:00</published><updated>2012-12-03T16:42:36.290-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-03T16:42:36.290-05:00</app:edited><title>Enabling Developer Options on Jelly Bean</title><content type="html">&lt;span style="background-color: white; color: #222225; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;If you have recently updated to 4.2 on one of your Nexus devices, you may have noticed that Developer Options is&amp;nbsp;mysteriously&amp;nbsp;missing from the setting menu. After&amp;nbsp;frantically&amp;nbsp;trying to it with no luck, you probably went to the web to find out where it went (just like I did).&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white; color: #222225; font-family: Arial, Helvetica, sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style="color: #222225; font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;To enable Developer Options in Android 4.2, go to Settings-&amp;gt;About Phone. Once there click on Build number 7 times.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222225; font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="color: #222225; font-family: Arial, Helvetica, sans-serif; font-size: x-small;"&gt;I'm not sure if this is just the Android team playing a prank on all the developers, or pretty cool Easter Egg. Hats off to the guys over at &lt;a href="http://forum.xda-developers.com/showthread.php?t=1989777" target="_blank"&gt;XDA &lt;/a&gt;for finding this.&lt;/span&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/vAiu1IYZipM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/5451451172859418804/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/12/enabling-developer-options-on-jelly-bean.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/5451451172859418804?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/5451451172859418804?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/vAiu1IYZipM/enabling-developer-options-on-jelly-bean.html" title="Enabling Developer Options on Jelly Bean" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/12/enabling-developer-options-on-jelly-bean.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QGQ3Y6fSp7ImA9WhNXEEg.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-3104907540236947516</id><published>2012-11-27T16:22:00.000-05:00</published><updated>2012-11-27T16:22:02.815-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-27T16:22:02.815-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="quality" /><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="opinion" /><category scheme="http://www.blogger.com/atom/ns#" term="knowledge" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="software design" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="practice" /><category scheme="http://www.blogger.com/atom/ns#" term="architecture" /><title>Coding for the Changes You'll Have to Make Next Month</title><content type="html">One of the most difficult parts of software development is adapting to change. It's a guarantee that the concepts, ideas, and possibly the point of the program that you are writing will change several times before it's actually done.&lt;br /&gt;
&lt;br /&gt;
If you have ever heard the buzzwords like &lt;a href="http://en.wikipedia.org/wiki/Agile_software_development"&gt;Agile&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Scrum_(development)"&gt;Scrum&lt;/a&gt;, &lt;a href="http://www.extremeprogramming.org/"&gt;Extreme Programming&lt;/a&gt;, or anything similar, then you have put some time into writing software that adapts to change. Any programmer serious about the craft has at least heard about it, but few have actually mastered it (and neither have I). Designing a program that easily adapts to change is a very difficult task. However, there are a few good ideas I have found that help create this kind of software at a team level:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Spend more time on design! Seriously, spend a few days or weeks on it. Time put into simply designing the software and not touching the code itself is time well spent. The better your design, the less pain will come your way down the road when the product is getting ready to ship.&lt;/li&gt;
&lt;li&gt;Think about what type of changes could come in the future. What would need to change in the system to let these new features exists? The smaller the effect on the entire system, the better.&lt;/li&gt;
&lt;li&gt;Step back from the requirements of the system for a moment and ask yourself why the system is designed in a particular way.&lt;/li&gt;
&lt;li&gt;What is going to happen when you run out of time (which you will)? Where do you think shortcuts will be made?&lt;/li&gt;
&lt;/ul&gt;
After designing a system, spend a few days (yes, &lt;i&gt;days&lt;/i&gt;) thinking about possible additions to the system. Don't just rush into coding up the system after you have one working solution. With these ideas, think about how the system would have to change to accommodate this new idea.&amp;nbsp;It really doesn't matter if these additions are realistic, feasible, or something that no one would really want in the program. If it's difficult to add to the current system, then maybe the system should be redesigned to accommodate it.&lt;br /&gt;
&lt;br /&gt;
The other trick is really just refactoring-- but taking it to the extreme. Any and every chance to refactor some code to make it more readable, useable, and simpler, should be taken. Don't let confusing, complicated code stick around in the code base just because you have more important things to do, or you didn't code it yourself. If the code doesn't make sense or is difficult to understand, get with the programmer who wrote it, and make it simpler. At the very least, understand what caused the code to become so complex and avoid that path next time. You'll save yourself a ton of time in the long run of the project, and by making the code simpler, it will be much easier to change later on.&lt;br /&gt;
&lt;blockquote class="tr_bq"&gt;
"Anytime you find yourself looking at a class's implementation to figure out how to use the class, you're not programming to the interface, you're programming through the interface to the implementation. If you're programming through the interface, encapsulation is broken, and once encapsulation starts to break down, abstraction won't be too far behind."[1]&amp;nbsp;&lt;/blockquote&gt;
Basically, this quote says if you have to look how a class/method/function works to figure it out, you're doing it wrong. Proper design hides this information well so that once it's written, it can be taken for granted.&amp;nbsp;This is an excellent time to refactor and think about how the code really should be structured.&lt;br /&gt;
&lt;br /&gt;
What ideas and concepts do you use to create adaptable software?&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-size: 11px;"&gt;
1. &lt;a href="http://www.amazon.com/gp/product/0735619670/ref=as_li_qf_sp_asin_tl?ie=UTF8&amp;amp;camp=1789&amp;amp;creative=9325&amp;amp;creativeASIN=0735619670&amp;amp;linkCode=as2&amp;amp;tag=programobile-20"&gt;Code Complete: A Practical Handbook of Software Construction, Second Edition&lt;/a&gt;&lt;img alt="" border="0" height="1" src="http://www.assoc-amazon.com/e/ir?t=programobile-20&amp;amp;l=as2&amp;amp;o=1&amp;amp;a=0735619670" style="border: none !important; margin: 0px !important;" width="1" /&gt;
- Chapter 6 - page 19&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/g_jtTGPvTAE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/3104907540236947516/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/11/coding-for-changes-you-have-to-make.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3104907540236947516?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3104907540236947516?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/g_jtTGPvTAE/coding-for-changes-you-have-to-make.html" title="Coding for the Changes You&amp;#39;ll Have to Make Next Month" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/11/coding-for-changes-you-have-to-make.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIBRXwyeip7ImA9WhNXEEg.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-3664770584829972076</id><published>2012-11-21T08:00:00.000-05:00</published><updated>2012-11-27T17:15:54.292-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-27T17:15:54.292-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="racquet" /><category scheme="http://www.blogger.com/atom/ns#" term="racquetball" /><category scheme="http://www.blogger.com/atom/ns#" term="ball" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="RB" /><category scheme="http://www.blogger.com/atom/ns#" term="RBRecorder" /><title>RBRecorder Redesigned</title><content type="html">After a fair amount of feedback from users, RBRecorder has been redesigned from the ground up and is now available on &lt;a href="https://play.google.com/store/apps/details?id=com.itaylor.rbrecorder"&gt;Google Play&lt;/a&gt;! RBRecorder makes refereeing a Racquetball match much easier and simpler. The new app includes:&lt;br /&gt;
&lt;ul&gt;
&lt;a href="http://1.bp.blogspot.com/-1GwGflhwb5g/UKv_zRHRe2I/AAAAAAAAED8/irEDs_fCljQ/s1600/google+play+1.png" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"&gt;&lt;img border="0" height="320" src="http://1.bp.blogspot.com/-1GwGflhwb5g/UKv_zRHRe2I/AAAAAAAAED8/irEDs_fCljQ/s320/google+play+1.png" width="192" /&gt;&lt;/a&gt;
&lt;li&gt;A completely revamped UI&lt;/li&gt;
&lt;li&gt;Historical match tracking&lt;/li&gt;
&lt;li&gt;Doubles support&lt;/li&gt;
&lt;li&gt;Comment support for matches and games&lt;/li&gt;
&lt;li&gt;Support for Matches longer or shorter than 3 games&lt;/li&gt;
&lt;li&gt;Support for games with any score or timeout limit&lt;/li&gt;
&lt;/ul&gt;
This release also comes with a promise of many new features in the near future, such as:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;More detailed stat information&lt;/li&gt;
&lt;li&gt;Match summery statics with the ability to email match info&lt;/li&gt;
&lt;/ul&gt;
Go check it out!&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/orlOY1ZcPRM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/3664770584829972076/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/11/rbrecorder-redesigned.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3664770584829972076?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3664770584829972076?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/orlOY1ZcPRM/rbrecorder-redesigned.html" title="RBRecorder Redesigned" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-1GwGflhwb5g/UKv_zRHRe2I/AAAAAAAAED8/irEDs_fCljQ/s72-c/google+play+1.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/11/rbrecorder-redesigned.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4CRXszfip7ImA9WhNREUk.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-5347323030822634586</id><published>2012-11-05T15:22:00.001-05:00</published><updated>2012-11-05T15:22:44.586-05:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-05T15:22:44.586-05:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="starter" /><category scheme="http://www.blogger.com/atom/ns#" term="application" /><category scheme="http://www.blogger.com/atom/ns#" term="Expirements" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="creator" /><category scheme="http://www.blogger.com/atom/ns#" term="generator" /><category scheme="http://www.blogger.com/atom/ns#" term="third party" /><title>App Starters for Android - Worth the Effort?</title><content type="html">&lt;p&gt;Over the last month or so I've seen a few simple projects pop up on Hacker News that help with creating an Android App.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Android KickStartr: &lt;a href="http://androidkickstartr.com/"&gt;http://androidkickstartr.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Android Bootstrap: &lt;a style="color: #828282; text-decoration: underline; font-family: Verdana; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; background-color: #f6f6ef;" rel="nofollow" href="http://www.androidbootstrap.com/"&gt;http://www.androidbootstrap.com/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Both projects allow you to punch some basic info. in about your application, and they output a formatted project file that's tuned to your application. The nice thing about these projects is that they contain many of the most commonly used libraries out there today.&lt;/p&gt;
&lt;p&gt;Both projects add the &lt;a href="http://actionbarsherlock.com/"&gt;ActionBarSherlock&lt;/a&gt; library, which allows you to have a nice Android-like Title Bar in apps well below 4.0. They both also add the &lt;a href="http://developer.android.com/tools/extras/support-library.html"&gt;Support Library&lt;/a&gt;, which gives a pre-3.0 app access to some of the new constructs like &lt;a href="http://developer.android.com/guide/components/fragments.html"&gt;Fragments&lt;/a&gt;. KickStartr gives you a bit more of customization ability by selecting which libraries you would like to include, while AndroidBootstrap gives no choices, but a deeper list of libraries.&lt;/p&gt;
&lt;p&gt;Both projects can get the job done, and they save you a bit of time by setting up all the annoying libraries for you. If you're starting a new project soon, they are certainly worth considering.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/9PZe5_8-RiU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/5347323030822634586/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/11/app-starters-for-android-worth-effort.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/5347323030822634586?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/5347323030822634586?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/9PZe5_8-RiU/app-starters-for-android-worth-effort.html" title="App Starters for Android - Worth the Effort?" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/11/app-starters-for-android-worth-effort.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIHQH87eSp7ImA9WhNSFk8.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-9182636277136391114</id><published>2012-10-30T14:40:00.001-04:00</published><updated>2012-10-30T14:42:11.101-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-30T14:42:11.101-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="Filter" /><category scheme="http://www.blogger.com/atom/ns#" term="data structures" /><category scheme="http://www.blogger.com/atom/ns#" term="Computer" /><category scheme="http://www.blogger.com/atom/ns#" term="Set" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Science" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="Expirements" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Bloom" /><title>Bloom Filter Implementation in Java on GitHub</title><content type="html">A &lt;a href="http://en.wikipedia.org/wiki/Bloom_filter" target="_blank"&gt;Bloom Filter&lt;/a&gt; is a type of &lt;a href="http://en.wikipedia.org/wiki/Set_(abstract_data_type)" target="_blank"&gt;Set Data Structure&lt;/a&gt;. For&amp;nbsp;those&amp;nbsp;unaware, a Set Data Structure only has one main method, contains. It's only used to determine if a specific element is included in a group of elements or not. Most Data Structures (like a &lt;a href="http://en.wikipedia.org/wiki/Hash_table" target="_blank"&gt;Hash Map&lt;/a&gt;, &lt;a href="http://en.wikipedia.org/wiki/Linked_list" target="_blank"&gt;Linked List&lt;/a&gt;, or &lt;a href="http://en.wikipedia.org/wiki/Array" target="_blank"&gt;Array&lt;/a&gt;) can create this function fairly easily. You simply need to &lt;a href="http://en.wikipedia.org/wiki/Search_data_structure" target="_blank"&gt;search&lt;/a&gt; the data&amp;nbsp;structure&amp;nbsp;for the specific element.&lt;br /&gt;
&lt;br /&gt;
However, these types of Data Structures&amp;nbsp;can pose a problem when the number of elements in the set exceeds the amount of memory&amp;nbsp;available, as these types of data&amp;nbsp;structures&amp;nbsp;store all of the elements in memory.&lt;br /&gt;
&lt;br /&gt;
This is where the Bloom Filter becomes interesting. As the Bloom Filter &lt;i&gt;doesn't &lt;/i&gt;actually store all of the elements of the set in memory.&lt;br /&gt;
&lt;br /&gt;
Instead of placing each element into a the Data Structure, the Bloom Filter only stores an array of bytes. For each element added to the Bloom Filter, k bits are set in its array. These bits are typically determined by a hashing function.&lt;br /&gt;
&lt;br /&gt;
To check if an element is within the set, you simply check if the bits that would normally be one for this item are actually one. If they all are one (instead of zero), then the item is within the set. If any of the bits are not one, then the item is not within the set.&lt;br /&gt;
&lt;br /&gt;
With every Data Structure there is&amp;nbsp;definitely&amp;nbsp;a draw back to the Bloom Filter. By using the method above, the Bloom Filter can say an element is within the set when it actually isn't. False&amp;nbsp;positives&amp;nbsp;are possible in the set, and they depend on several factors, such as:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The size of the byte array&lt;/li&gt;
&lt;li&gt;The number of bits (k) set per element&lt;/li&gt;
&lt;li&gt;The number of items in the set&lt;/li&gt;
&lt;/ul&gt;
By tweaking the above values, you can easily get the false&amp;nbsp;positive&amp;nbsp;probability to respectable levels while still saving a large amount of space.&lt;br /&gt;
&lt;br /&gt;
After I discovered the Bloom Filter, I went looking for an implementation in Java. Sadly, a standard implementation doesn't exist! So, I wrote a quick and simple version of the Bloom Filter for Java. You can find the &lt;a href="https://github.com/ProMobile/BloomFilter" target="_blank"&gt;source code &lt;/a&gt;on GitHub.&lt;br /&gt;
&lt;br /&gt;
My implementation uses:&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;MD5 Hash  &lt;ul&gt;
&lt;li&gt;To add an Object, the set takes the value of the hashCode() method to compute the MD5 hash. For subsequent values of k, the filter uses the previously computed MD5 hash (converted to an int) to generate the new MD5 hash.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Backed by a simple byte array&lt;/li&gt;
&lt;li&gt;Implements the Set&amp;lt;Object&amp;gt; interface, although some of the methods in the interface will not work properly.&lt;/li&gt;
&lt;/ul&gt;
Note that the project also used the &lt;a href="http://sizeof.sourceforge.net/" target="_blank"&gt;SizeOf&lt;/a&gt; Library to get the number of byte used in memory.&lt;br /&gt;
I also did a few quick expirements to compare the filter to a standard ArrayList in Java and a few performance checks.&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Time required to add an element to the set using different k values  &lt;/li&gt;
&lt;li&gt;Size of the set versus the array list at different levels&lt;/li&gt;
&lt;/ul&gt;
As to be expected, the larger the number of elements required to be in the set, the more useful the Bloom Filter becomes. It does get a bit tricky when determining how large the Bloom Filter should be&amp;nbsp;&lt;span style="background-color: white;"&gt;and what&amp;nbsp;&lt;/span&gt;the optimal k value is for a given set, especially if the set is continually growing.&lt;br /&gt;
&lt;br /&gt;
For the tests, I simply added Objects (which have a size of 16 bytes) to each data structure, and I then use the SizeOf library to get the true amount of space used.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-GUwJtwNyfLk/UIQ2RaPVApI/AAAAAAAADaw/QCqgJmw_Qmw/s1600/bloom+filter+-+ds+size.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="285" src="http://3.bp.blogspot.com/-GUwJtwNyfLk/UIQ2RaPVApI/AAAAAAAADaw/QCqgJmw_Qmw/s400/bloom+filter+-+ds+size.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
From the above graph, its easy to see that the Bloom Filter is much more efficient on size once the array becomes larger than 100 objects. That trend continues &lt;span style="background-color: white;"&gt;at&amp;nbsp;1500 objects&lt;/span&gt;, with the Bloom Filter requiring 22808 bytes less than the ArrayList to store the same amount of elements.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-HP8_vDwvN9E/UIQ2TLL2jQI/AAAAAAAADa4/5yi7Z4aVcvk/s1600/bloom+filter+-+time+to+add.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="285" src="http://2.bp.blogspot.com/-HP8_vDwvN9E/UIQ2TLL2jQI/AAAAAAAADa4/5yi7Z4aVcvk/s400/bloom+filter+-+time+to+add.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
The above graph shows the time in seconds (on an early 2012 iMac) to add an element to the list with different numbers of bits set (k). As k increases, the time increases fairly slowly up to 10 bits. However, anything past 10 &lt;span style="background-color: white;"&gt;becomes very&amp;nbsp;costly&lt;/span&gt;, with 100 bits set requiring a full second to complete.&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: left;"&gt;
Feel free to check out the source code for the tests and the Bloom Filter implementation itself on &lt;a href="https://github.com/ProMobile/BloomFilter" target="_blank"&gt;GitHub&lt;/a&gt;.&lt;/div&gt;
&lt;br /&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/sV1yhail1cY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/9182636277136391114/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/10/bloom-filter.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/9182636277136391114?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/9182636277136391114?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/sV1yhail1cY/bloom-filter.html" title="Bloom Filter Implementation in Java on GitHub" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-GUwJtwNyfLk/UIQ2RaPVApI/AAAAAAAADaw/QCqgJmw_Qmw/s72-c/bloom+filter+-+ds+size.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/10/bloom-filter.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMDQXo8cCp7ImA9WhNSEE8.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-8616618101360688311</id><published>2012-10-23T16:34:00.001-04:00</published><updated>2012-10-23T16:34:30.478-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-23T16:34:30.478-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="Ipad" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="iOS" /><category scheme="http://www.blogger.com/atom/ns#" term="iphone" /><category scheme="http://www.blogger.com/atom/ns#" term="objective c" /><title>A Reason to Write Android Apps First</title><content type="html">&lt;p&gt;If you work on a mobile app and you're planning on developing it on Android and iOS, it may be less work for you to write it on Android first. Google recently released a new tool that makes porting Java code to iOS much easier.&lt;br /&gt;The project (j2objc) can be found &lt;a href="https://code.google.com/p/j2objc/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To give the program a quick test run, I ran it using this Java file:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #b933a1;"&gt;public&lt;span style="color: #000000;"&gt; &lt;/span&gt;class&lt;span style="color: #000000;"&gt; hello {&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;&lt;span style="color: #b933a1;"&gt; public&lt;/span&gt; &lt;span style="color: #b933a1;"&gt;static&lt;/span&gt; &lt;span style="color: #b933a1;"&gt;void&lt;/span&gt; main(String[] args) {&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;System.out.println(&lt;span style="color: #cf3125;"&gt;"To Objective C we go!"&lt;/span&gt;);&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;}&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;}&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;After running the above code using j2objc, I received two files (as expected): the header file, hello.h, and the source file, hello.m. The source file looks like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008212;"&gt;//&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008212;"&gt;//  Generated by the J2ObjC translator.  DO NOT EDIT!&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008212;"&gt;//  source: hello.java&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008212;"&gt;//&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008212;"&gt;//  Created by Isaac on 10/18/12.&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #008212;"&gt;//&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #cf3125;"&gt;&lt;span style="color: #77492d;"&gt;#import &lt;/span&gt;"IOSObjectArray.h"&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #cf3125;"&gt;&lt;span style="color: #77492d;"&gt;#import &lt;/span&gt;"hello.h"&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #b933a1;"&gt;@implementation&lt;span style="color: #000000;"&gt; hello&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #b933a1;"&gt;@end&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;&lt;span style="color: #b933a1;"&gt;int&lt;/span&gt; main( &lt;span style="color: #b933a1;"&gt;int&lt;/span&gt; argc, &lt;span style="color: #b933a1;"&gt;const&lt;/span&gt; &lt;span style="color: #b933a1;"&gt;char&lt;/span&gt; *argv[] ) {&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;&lt;span style="color: #b933a1;"&gt; int&lt;/span&gt; exitCode = &lt;span style="color: #2934d5;"&gt;0&lt;/span&gt;;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;NSAutoreleasePool *pool = [[NSAutoreleasePool         alloc] init];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;IOSObjectArray *args = J                               reEmulationMainArguments(argc, argv);&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #cf3125;"&gt;&lt;span style="color: #000000;"&gt; NSLog(&lt;/span&gt;@"%@"&lt;span style="color: #000000;"&gt;, &lt;/span&gt;@"To Objective C we go!"&lt;span style="color: #000000;"&gt;);&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; min-height: 13.0px;"&gt; &lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;[pool release];&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;&lt;span style="color: #b933a1;"&gt; return&lt;/span&gt; exitCode;&lt;/p&gt;
&lt;p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo;"&gt;}&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;J2Objc certainly has to make a few decisions when converting between the two languages. One is seen above, as System.out.printLn is converted to NSLog. Currently J2Objc can convert much of Java, including things like reflection and anonymous classes in Java. I imagine these kinds of decisions are made through the program.&lt;/p&gt;
&lt;p&gt;Although the library can't touch any specific Java code related to the Android APIs, it can handle anything written in pure Java. The tool certainly has potential, especially for converting standard java classes directly to their Objective C equivalent.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/1XtrEpjvoqc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/8616618101360688311/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/10/a-reason-to-write-android-apps-first.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/8616618101360688311?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/8616618101360688311?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/1XtrEpjvoqc/a-reason-to-write-android-apps-first.html" title="A Reason to Write Android Apps First" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/10/a-reason-to-write-android-apps-first.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A08HSXc6cCp7ImA9WhNTFE8.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-5057803280361091470</id><published>2012-10-16T19:23:00.001-04:00</published><updated>2012-10-16T19:23:58.918-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-16T19:23:58.918-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="data structures" /><category scheme="http://www.blogger.com/atom/ns#" term="knowledge" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="practice" /><title>Advance Data Structures from MIT</title><content type="html">&lt;p&gt;Up for learning about some new Data Structures? MIT just released some vidoes from their Spring 2012 Advanced Data Structures class.&lt;/p&gt;
&lt;p&gt;The first lecture goes on about the Pointer Machine style, as well as Temoral Data Structures (sounds interesting, right?). I'm sure there are some really interesting things hidden in these videos, which can be found &lt;a href="http://courses.csail.mit.edu/6.851/spring12/lectures/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I imagine I'll be posting a few more articles as I run through the lectures.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/jMM4nwuMtRM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/5057803280361091470/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/10/advance-data-structures-from-mit.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/5057803280361091470?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/5057803280361091470?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/jMM4nwuMtRM/advance-data-structures-from-mit.html" title="Advance Data Structures from MIT" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/10/advance-data-structures-from-mit.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0cASXw-eyp7ImA9WhNTEEo.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-1613591049632114728</id><published>2012-10-09T15:12:00.001-04:00</published><updated>2012-10-12T15:44:08.253-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-12T15:44:08.253-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="database" /><title>Android Tutorial: Finding the SD Card Path</title><content type="html">Finding the SD Card path in Android is easy right? All you have to do is use &lt;a href="http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()" target="_blank"&gt;Environment.getExternalStorageDirectory()&lt;/a&gt;, and you’re good to go! &lt;br /&gt;
Well, not quite.&lt;br /&gt;
After all, that’s what &lt;a href="http://stackoverflow.com/questions/1209469/storing-android-application-data-on-sd-card" target="_blank"&gt;StackOverflow&lt;/a&gt; says. If you actually try the above method on a Samsung device, life won’t be fun for you. Environment.getExternalStoreDirectory() actually returns the incorrect path on most Samsung devices. That’s how I came across the issue. It turns out, the above method doesn’t actually guarantee that it will return the SD Card directory. According to Android’s API &lt;a href="http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()" target="_blank"&gt;documentation&lt;/a&gt;, &lt;br /&gt;
“In devices with multiple ‘external’ storage directories (such as both secure app storage and mountable shared storage), this directory represents the ‘primary’ external storage that the user will interact with.”&lt;br /&gt;
So the call doesn’t guarantee that the path returned truly points SD Card. There are a few other ways to get an “external” path on the device where files can be stored, though, like the &lt;a href="http://developer.android.com/reference/android/content/Context.html#getExternalFilesDir%28java.lang.String%29" target="_blank"&gt;getExternalFilesDir()&lt;/a&gt;. &lt;br /&gt;
There are also a few other tricks to actually get the path of the SD Card directory. The below code works on most Android devices (Samsung included). It’s a pretty hacky solution, though, and who knows how long this trick will actually work (&lt;a href="http://stackoverflow.com/questions/5524105/how-could-i-get-the-correct-external-storage-on-samsung-and-all-other-devices" target="_blank"&gt;source&lt;/a&gt;). Instead of using the code below, it may be better to ask the question, “do I really need the SD Card directory, or just a path that I can store files to?”&lt;br /&gt;
&lt;div id="codeSnippetWrapper" style="background-color: #f4f4f4; border-bottom: silver 1px solid; border-left: silver 1px solid; border-right: silver 1px solid; border-top: silver 1px solid; cursor: text; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; height: 235px; line-height: 12pt; margin: 20px 0px 10px; max-height: 200px; overflow: auto; padding-bottom: 4px; padding-left: 4px; padding-right: 4px; padding-top: 4px; text-align: left; width: 97.5%;"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt;   1:&lt;/span&gt; File file = &lt;span style="color: blue;"&gt;new&lt;/span&gt; File(&lt;span style="color: #006080;"&gt;"/system/etc/vold.fstab"&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt;   2:&lt;/span&gt;   FileReader fr = null;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt;   3:&lt;/span&gt;   BufferedReader br = null;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt;   4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt;   5:&lt;/span&gt;   &lt;span style="color: blue;"&gt;try&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt;   6:&lt;/span&gt;       fr = &lt;span style="color: blue;"&gt;new&lt;/span&gt; FileReader(file);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt;   7:&lt;/span&gt;   } &lt;span style="color: blue;"&gt;catch&lt;/span&gt; (FileNotFoundException e) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt;   8:&lt;/span&gt;       e.printStackTrace();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt;   9:&lt;/span&gt;   } &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt;  10:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt;  11:&lt;/span&gt;   &lt;span style="color: blue;"&gt;try&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt;  12:&lt;/span&gt;       &lt;span style="color: blue;"&gt;if&lt;/span&gt; (fr != null) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt;  13:&lt;/span&gt;           br = &lt;span style="color: blue;"&gt;new&lt;/span&gt; BufferedReader(fr);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt;  14:&lt;/span&gt;           String s = br.readLine();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt;  15:&lt;/span&gt;           &lt;span style="color: blue;"&gt;while&lt;/span&gt; (s != null) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt;  16:&lt;/span&gt;               &lt;span style="color: blue;"&gt;if&lt;/span&gt; (s.startsWith(&lt;span style="color: #006080;"&gt;"dev_mount"&lt;/span&gt;)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum17" style="color: #606060;"&gt;  17:&lt;/span&gt;                   String[] tokens = s.split(&lt;span style="color: #006080;"&gt;"\\s"&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum18" style="color: #606060;"&gt;  18:&lt;/span&gt;                   path = tokens[2]; &lt;span style="color: green;"&gt;//mount_point&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum19" style="color: #606060;"&gt;  19:&lt;/span&gt;                   &lt;span style="color: blue;"&gt;if&lt;/span&gt; (!Environment.getExternalStorageDirectory().getAbsolutePath().equals(path)) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum20" style="color: #606060;"&gt;  20:&lt;/span&gt;                       &lt;span style="color: blue;"&gt;break&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum21" style="color: #606060;"&gt;  21:&lt;/span&gt;                   }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum22" style="color: #606060;"&gt;  22:&lt;/span&gt;               }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum23" style="color: #606060;"&gt;  23:&lt;/span&gt;               s = br.readLine();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum24" style="color: #606060;"&gt;  24:&lt;/span&gt;           }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum25" style="color: #606060;"&gt;  25:&lt;/span&gt;       }            &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum26" style="color: #606060;"&gt;  26:&lt;/span&gt;   } &lt;span style="color: blue;"&gt;catch&lt;/span&gt; (IOException e) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum27" style="color: #606060;"&gt;  27:&lt;/span&gt;       e.printStackTrace();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum28" style="color: #606060;"&gt;  28:&lt;/span&gt;   } &lt;span style="color: blue;"&gt;finally&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum29" style="color: #606060;"&gt;  29:&lt;/span&gt;       &lt;span style="color: blue;"&gt;try&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum30" style="color: #606060;"&gt;  30:&lt;/span&gt;           &lt;span style="color: blue;"&gt;if&lt;/span&gt; (fr != null) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum31" style="color: #606060;"&gt;  31:&lt;/span&gt;               fr.close();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum32" style="color: #606060;"&gt;  32:&lt;/span&gt;           }            &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum33" style="color: #606060;"&gt;  33:&lt;/span&gt;           &lt;span style="color: blue;"&gt;if&lt;/span&gt; (br != null) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum34" style="color: #606060;"&gt;  34:&lt;/span&gt;               br.close();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum35" style="color: #606060;"&gt;  35:&lt;/span&gt;           }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum36" style="color: #606060;"&gt;  36:&lt;/span&gt;       } &lt;span style="color: blue;"&gt;catch&lt;/span&gt; (IOException e) {&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum37" style="color: #606060;"&gt;  37:&lt;/span&gt;           e.printStackTrace();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: #f4f4f4; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum38" style="color: #606060;"&gt;  38:&lt;/span&gt;       }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;br /&gt;
&lt;pre style="background-color: white; border-bottom-style: none; border-left-style: none; border-right-style: none; border-top-style: none; color: black; direction: ltr; font-family: 'Courier New', courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum39" style="color: #606060;"&gt;  39:&lt;/span&gt;   }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/0vCg4UeQZNY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/1613591049632114728/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/10/android-tutorial-finding-sd-card-path.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/1613591049632114728?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/1613591049632114728?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/0vCg4UeQZNY/android-tutorial-finding-sd-card-path.html" title="Android Tutorial: Finding the SD Card Path" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/10/android-tutorial-finding-sd-card-path.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU8GR3Y8eSp7ImA9WhJVF0g.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-2249665621789277882</id><published>2012-09-04T07:23:00.001-04:00</published><updated>2012-09-04T07:23:46.871-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-04T07:23:46.871-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="quality" /><category scheme="http://www.blogger.com/atom/ns#" term="frameworks" /><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="Testing" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="TDD" /><title>Android and Jenkins: Continuous Integration</title><content type="html">&lt;p&gt;By using &lt;a href="http://jenkins-ci.org/" target="_blank"&gt;Jenkins&lt;/a&gt;, it’s pretty easy to get a Continuous Integration server set up with an Android project. But before you dive into setting up the software itself, it’s very helpful to have some basic concepts on a few different types of software that you will run into.&lt;/p&gt; &lt;p&gt;For those unaware, &lt;a href="http://en.wikipedia.org/wiki/Continuous_integration" target="_blank"&gt;Continuous Integration&lt;/a&gt; is a way to improve your code by following the “fail fast” concept. If any bug or problem crops up in your application, you want to find them as early as possible. By building and testing your application frequently, you can do just that. By finding the bug quickly, it will be easier to fix the problem, as the code was written recently.&lt;/p&gt; &lt;p&gt;What CI really does for you is two things:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Compiles the application when any new changes are checked in  &lt;li&gt;Runs automated tests every time we recompile&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;So CI is really only helpful if you are growing your &lt;a href="http://en.wikipedia.org/wiki/Unit_testing" target="_blank"&gt;Unit Tests&lt;/a&gt; as well as your application. Without the tests to support your application, Continuous Integration quickly loses its usefulness.&lt;/p&gt; &lt;p&gt;Jenkins is really an automated build server for a number of different types of applications. Jenkins itself is written in Java, so it’s only natural for it to support Java projects at its core, which works out great for Android.&lt;/p&gt; &lt;h2&gt;Jenkins Plugins&lt;/h2&gt; &lt;p&gt;One of the really awesome things about Jenkins is it’s plugin capability. Jenkins alone can pull your software (from SVN) and build it, if you’re a Java project, but that’s really it. By adding a few plugins, you can add some more interesting and useful features. Without a handful of plugins, using Jenkins as a CI server wouldn’t be possible.&lt;/p&gt; &lt;p&gt;For Android, these two Jenkins plugins are incredibly useful:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="https://wiki.jenkins-ci.org/display/JENKINS/Android+Emulator+Plugin" target="_blank"&gt;Android Emulator&lt;/a&gt;  &lt;ul&gt; &lt;li&gt;Allows automated unit testing using the emulator&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;&lt;a href="https://wiki.jenkins-ci.org/display/JENKINS/xUnit+Plugin" target="_blank"&gt;xUnit&lt;/a&gt;  &lt;ul&gt; &lt;li&gt;Improves the basic jUnit support of Jenkins&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Ant&lt;/h2&gt; &lt;p&gt;When using Jenkins, some basic knowledge of &lt;a href="http://ant.apache.org/" target="_blank"&gt;Ant&lt;/a&gt; is also necessary. If you’re building Android projects with Eclipse, you likely don’t ever deal with the configuration that is required to build your application. With Jenkins, you have to do a bit of work to get it building properly by creating an Ant script for your app.&lt;/p&gt; &lt;p&gt;I won’t go into the details of actually creating an Ant script. You can find more info. on Ant from the above link, and this blog post helps immensely when generating the script from scratch.&lt;/p&gt; &lt;h2&gt;Unit Testing&lt;/h2&gt; &lt;p&gt;&lt;a href="http://code.google.com/p/robotium/" target="_blank"&gt;Robodium&lt;/a&gt; is a framework that beefs up Android Unit Test capabilities. It allows much easier testing of UI elements within Android. If you are looking to write unit tests for your application, you should really check it out.&lt;/p&gt; &lt;p&gt;I hope this article helps you get the basics of what’s really needed for an Android CI server using Jenkins. To get into the details to truly set the server up, check out this blog article:&lt;a href="http://blackriverweb.com/2012/02/android-continuous-integration-with-ant-and-jenkins-part-1/"&gt;http://blackriverweb.com/2012/02/android-continuous-integration-with-ant-and-jenkins-part-1/&lt;/a&gt;&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/BV8wKDS2Ou4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/2249665621789277882/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/09/android-and-jenkins-continuous.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/2249665621789277882?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/2249665621789277882?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/BV8wKDS2Ou4/android-and-jenkins-continuous.html" title="Android and Jenkins: Continuous Integration" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/09/android-and-jenkins-continuous.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUARHg_fCp7ImA9WhJVEU0.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-6216231217082378969</id><published>2012-08-27T16:44:00.000-04:00</published><updated>2012-08-27T16:44:05.644-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-27T16:44:05.644-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="EditText" /><category scheme="http://www.blogger.com/atom/ns#" term="Android TextView" /><category scheme="http://www.blogger.com/atom/ns#" term="link" /><category scheme="http://www.blogger.com/atom/ns#" term="web" /><category scheme="http://www.blogger.com/atom/ns#" term="hyper" /><title>How to Use Android's TextView as a Hyperlink</title><content type="html">With a few simple pieces of code, it's really easy to convert a &lt;a href="http://developer.android.com/reference/android/widget/TextView.html" target="_blank"&gt;TextView &lt;/a&gt;into a hyperlink, which opens the default browser outside your app.&lt;br /&gt;
&lt;br /&gt;
Just follow these steps:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style="font-family: inherit;"&gt;Set the text of the TextView with a bit of HTML (by using the &lt;a href="http://html.fromhtm/" target="_blank"&gt;Html.fromHTM&lt;/a&gt;L method, or by using the strings.xml file)&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style="font-family: Courier New, Courier, monospace;"&gt;"&lt;span style="line-height: 18px;"&gt;&amp;lt;a&lt;/span&gt;&lt;span style="color: maroon; line-height: 18px;"&gt; &lt;/span&gt;&lt;span style="line-height: 18px;"&gt;href=\"http://www.programmingmobile.com\"&amp;gt;ProMobile&amp;lt;/a&amp;gt;"&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="line-height: 18px;"&gt;Set the &lt;a href="http://developer.android.com/reference/android/widget/TextView.html#setMovementMethod(android.text.method.MovementMethod)" target="_blank"&gt;MovementMethod &lt;/a&gt;of the TextView with&amp;nbsp;&lt;/span&gt;&lt;span class="typ" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;LinkMovementMethod&lt;/span&gt;&lt;span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;.&lt;/span&gt;&lt;span class="pln" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;getInstance&lt;/span&gt;&lt;span class="pun" style="border: 0px; line-height: 18px; margin: 0px; padding: 0px; vertical-align: baseline;"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;span style="line-height: 18px;"&gt;That's it! It is important to note that this method does cause the link to open outside the control of your application. If you want the link to open within your app, you should open the link within a &lt;a href="http://developer.android.com/reference/android/webkit/WebView.html" target="_blank"&gt;WebView&lt;/a&gt;&amp;nbsp;instead.&lt;/span&gt;&lt;/div&gt;
&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/fY3psIe88SY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/6216231217082378969/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/08/how-to-use-androids-textview-as.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/6216231217082378969?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/6216231217082378969?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/fY3psIe88SY/how-to-use-androids-textview-as.html" title="How to Use Android's TextView as a Hyperlink" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/08/how-to-use-androids-textview-as.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUAR307eCp7ImA9WhJWEEk.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-3431165767803766310</id><published>2012-08-14T18:15:00.000-04:00</published><updated>2012-08-15T10:50:46.300-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-15T10:50:46.300-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Button" /><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Compound" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="UI Design" /><category scheme="http://www.blogger.com/atom/ns#" term="ListView" /><title>Why Code Assumptions are Bad - Quarks with Android's CheckBoxes and ListViews</title><content type="html">Last week I spent a few hours with a pretty annoying problem. I was developing a simple &lt;a href="http://developer.android.com/guide/topics/ui/layout/listview.html" target="_blank"&gt;List View&lt;/a&gt; that contained items with a Checkbox and a couple of &lt;a href="http://developer.android.com/reference/android/widget/TextView.html" target="_blank"&gt;TextViews&lt;/a&gt;. When a user would check a &lt;a href="http://developer.android.com/reference/android/widget/CheckBox.html" target="_blank"&gt;Checkbox &lt;/a&gt;on an item, that Checkbox state would be saved. The functionality should be that when the user scrolls away from a checked item, and they scroll back, the checked state should be refreshed.&lt;br /&gt;
&lt;br /&gt;
To set this up, I used the View &lt;a href="http://developer.android.com/reference/android/view/View.html#getTag(int)" target="_blank"&gt;tags &lt;/a&gt;functionality to map Checkbox states to a specific item in the list view.&amp;nbsp;Every time&amp;nbsp;a new view was created with the List View Adapter's &lt;a href="http://developer.android.com/reference/android/widget/Adapter.html#getView(int, android.view.View, android.view.ViewGroup)" target="_blank"&gt;getView &lt;/a&gt;call, it checked the view's tag to get the Checkbox state. This part worked like a charm. But despite the View tag mapping, the Checkbox state was still being lost after scrolling.&lt;br /&gt;
&lt;br /&gt;
After spending a few hours debugging the code, I finally figured out the problem. The problem involved yet another assumption that I had within the code.&lt;br /&gt;
&lt;br /&gt;
For a Checkbox, in order to receive a callback anytime the user interacts with the Checkbox, you can supply a&amp;nbsp;
OnCheckedChangedListener. This listener gets call anytime the user clicks on the Checkbox.&lt;br /&gt;
The deadly assumption that I made was that this callback &lt;i&gt;only &lt;/i&gt;is called when the user interacts with the Checkbox.&lt;br /&gt;
&lt;br /&gt;
I had my code set up like this within the getView call:&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Set the &lt;a href="http://developer.android.com/reference/android/widget/CompoundButton.html#setOnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener)" target="_blank"&gt;OnCheckedChangedListener&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Set the Checked state of the Checkbox by using the &lt;a href="http://developer.android.com/reference/android/widget/CompoundButton.html#setChecked(boolean)" target="_blank"&gt;setChecked &lt;/a&gt;method and using the View Tag functionality described above.&lt;/li&gt;
&lt;li&gt;And so on&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
This ordering is what burned me. It turns out, the setChecked method also triggers the OnCheckedChangedListener to be called. So anytime I set the state of the Checkbox, the&amp;nbsp;
OnCheckedChangedListener&amp;nbsp;would immediately call and wipe out the state I had just added.&lt;br /&gt;
&lt;br /&gt;
The fix is really easy. All I needed to do was just switch the order of the two calls above. Now, by setting the state &lt;i&gt;before &lt;/i&gt;I set the&amp;nbsp;
OnCheckedChangedListener, I have no problems.&lt;br /&gt;
&lt;br /&gt;
It just goes to show you, assumptions in code always come back to haunt you down the road.&amp;nbsp;I wish I could take credit for finding this silly mistake myself, but I did run across &lt;a href="http://stackoverflow.com/questions/2757121/android-listview-with-checkbox-automatically-unchecks" target="_blank"&gt;this StackOverflow&lt;/a&gt; post about it eventually.&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/rw2kGxYh6zA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/3431165767803766310/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/08/why-code-assumptions-are-bad-quarks.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3431165767803766310?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3431165767803766310?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/rw2kGxYh6zA/why-code-assumptions-are-bad-quarks.html" title="Why Code Assumptions are Bad - Quarks with Android&amp;#39;s CheckBoxes and ListViews" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/08/why-code-assumptions-are-bad-quarks.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUQASXc_cCp7ImA9WhJXE0o.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-3748146239106272414</id><published>2012-08-07T17:02:00.000-04:00</published><updated>2012-08-07T17:02:28.948-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-07T17:02:28.948-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="support" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="experience" /><category scheme="http://www.blogger.com/atom/ns#" term="Apple" /><category scheme="http://www.blogger.com/atom/ns#" term="web" /><category scheme="http://www.blogger.com/atom/ns#" term="hybrid" /><title>Android WebView CSS Support</title><content type="html">&lt;div&gt;
Creating &lt;a href="http://en.wikipedia.org/wiki/HTML5" target="_blank"&gt;HTML &lt;/a&gt;applications can be a great way to cut down development time between two platforms. The trend today is to develop a web app for iOS (with varing amount of native code) and simply use the HTML, &lt;a href="http://en.wikipedia.org/wiki/Cascading_Style_Sheets" target="_blank"&gt;CSS&lt;/a&gt;, and Javascript on other platforms like Android.&lt;br /&gt;
&lt;br /&gt;
The process can work well, and it can save you considerable time while still having a nice, polished app on multiple platforms. There are a few pitfalls with the approach, though. One of the main troubles is developing for iOS first.&lt;br /&gt;
&lt;br /&gt;
You see, iOS has a great in-app brower. It has support for all of the latest HTML5 components, it fully supports &lt;a href="http://www.css3.info/" target="_blank"&gt;CSS3&lt;/a&gt;, and it has great Javascript performance. The problem is, no other platform is near that level yet. This can create some issues when you are porting your HTML,CSS, and Javascript to other platforms, like Android.&lt;br /&gt;
&lt;br /&gt;
When following the pattern above, you should really develop for the lower platform first and then port to iOS. This way, you will have less development time lost to solving compabability issues.

Some of these issues could be:

Javascript &lt;a href="http://en.wikipedia.org/wiki/Document_Object_Model" target="_blank"&gt;DOM &lt;/a&gt;differences, CSS3 syntactical differences, and Javascript performance differences. Also, keep in mind that the usage of third party libraries, that may work great on iOS, may not work on other platforms. It may not even have an equivalent verison available.&lt;br /&gt;
&lt;br /&gt;
One thing to watch out for would be:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;span style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 14px; line-height: 14px; white-space: nowrap;"&gt;-webkit-linear-gradient... versus&amp;nbsp;&lt;/span&gt;
&lt;span style="font-family: Consolas, 'Courier New', Courier, mono; font-size: 14px; line-height: 14px; white-space: nowrap;"&gt;-webkit-gradient&lt;/span&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: white;"&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style="background-color: white;"&gt;I'm sure that there are several other major&amp;nbsp;differences&amp;nbsp;between what is supported between Android and iOS. Once I find more, I'll let you know.&lt;/span&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/gu0rrb0AJBU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/3748146239106272414/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/08/android-webview-css-support.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3748146239106272414?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3748146239106272414?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/gu0rrb0AJBU/android-webview-css-support.html" title="Android WebView CSS Support" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>1</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/08/android-webview-css-support.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcDQXg9eyp7ImA9WhJQEkk.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-4133190121014095134</id><published>2012-07-25T15:54:00.000-04:00</published><updated>2012-07-25T15:54:30.663-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-25T15:54:30.663-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="Sliding" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="tutorial" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="Widget" /><category scheme="http://www.blogger.com/atom/ns#" term="Drawer" /><title>Want to Add a Navigation Drawer to Your Android  App?</title><content type="html">Android's &lt;a href="http://developer.android.com/design/get-started/ui-overview.html"&gt;Navigation Drawer &lt;/a&gt;is one of the major features of an Android phone. The drawer gives the user access to things like notifications (someone just send you a text message), to system events (Wi-Fi has changed) to which apps are currently running (depending on what "skin" of Android is in use). The user can open the Nav Drawer by just swiping down from the &lt;a href="http://developer.android.com/guide/topics/ui/notifiers/notifications.html"&gt;Status Bar&lt;/a&gt;. The Nav bar also brings a unique animation to the device. The user can draw, hold, and flig the bar open or closed.&lt;br /&gt;
Wouldn't that kind of animation be cool to add to your own app? Many apps today are adding sliding menues (think Facebook, &lt;a href="https://play.google.com/store/apps/details?id=com.valvesoftware.android.steam.community&amp;amp;hl=en"&gt;Steam&lt;/a&gt;, etc..). Although they don't completely have the "swipe and play with" feel to it, it would be really nice to have. However finding the details on the &lt;a href="http://developer.android.com/reference/android/widget/SlidingDrawer.html"&gt;Sliding Drawer&lt;/a&gt; was a bit tougher than I thought. After some time, I did find exactly what I was looking for, so let me save you the trouble of looking for it. I found a great tutorial on the Sliding Drawer over on Android People (&lt;a href="http://www.androidpeople.com/android-sliding-drawer-tutorial"&gt;Android Sliding Drawer Tutorial&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
Have fun playing with it! The author is also kind enough to give the &lt;a href="http://www.androidpeople.com/wp-content/uploads/2010/07/SlidingDrawer.zip"&gt;full source&lt;/a&gt;&amp;nbsp;for the example project. Its great for just pulling it open and using whatever you would like.&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/Hf8psrtGOOc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/4133190121014095134/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/07/want-to-add-navigation-drawer-to-your.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/4133190121014095134?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/4133190121014095134?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/Hf8psrtGOOc/want-to-add-navigation-drawer-to-your.html" title="Want to Add a Navigation Drawer to Your Android  App?" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/07/want-to-add-navigation-drawer-to-your.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkIFQnc4eyp7ImA9WhJRFEo.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-9177608662851588923</id><published>2012-07-16T16:28:00.001-04:00</published><updated>2012-07-16T16:28:33.933-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-16T16:28:33.933-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="mobile" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="apps" /><category scheme="http://www.blogger.com/atom/ns#" term="Expirements" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="Google" /><title>Android Performance Tweaking: ParseArray Versus Hashmap</title><content type="html">&lt;p&gt;For the conclusion, just skip to the last section. &lt;/p&gt; &lt;p&gt;One of the more recent Android ADT updates added Android &lt;a href="http://tools.android.com/tips/lint/" target="_blank"&gt;Lint&lt;/a&gt;. Lint will check your Android project for simples things that you can change to improve your app. Lint notifies you about things like:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Unused resources  &lt;li&gt;Simple code changes to improve performance  &lt;li&gt;Inefficiencies in XML layouts such as nested weights or unused layouts&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;And a few other things. When I ran Lint the other day, I found one other performance tweak that was suggested by Lint. I was told that “for maps where keys are of type integer, it’s &lt;strong&gt;typically&lt;/strong&gt; more efficient to use the Android &lt;a href="http://developer.android.com/reference/android/util/SparseArray.html" target="_blank"&gt;SparseArray&lt;/a&gt; API”.&lt;img style="display: inline" src="http://tools.android.com/_/rsrc/1330041691886/recent/lintperformancechecks/sparsearrays.png" width="500" height="426"&gt;&lt;/p&gt; &lt;p align="center"&gt;&lt;em&gt;&lt;strong&gt;But when should A SparseArray be Used?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt; &lt;p align="left"&gt;After checking out the optimization a bit more, I couldn’t find a ton of data that says &lt;strong&gt;when&lt;/strong&gt; a &lt;a href="http://developer.android.com/reference/android/util/SparseArray.html" target="_blank"&gt;SpraseArray&lt;/a&gt; should be used over a &lt;a href="http://developer.android.com/reference/java/util/HashMap.html" target="_blank"&gt;Hashmap&lt;/a&gt;. Should it be used in every case where a Hashmap could have been used? What about if the array is small? How about if the range of values is under 500?&lt;/p&gt; &lt;p align="left"&gt;These are the kinds of questions I tried to answer with the experiment below. But before I jump right into the experiment details, it’s good to have some background information on Hashmaps and SparsArrays.&lt;/p&gt; &lt;p align="center"&gt;&lt;em&gt;&lt;strong&gt;What is a Hashmap?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;A &lt;a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/util/HashMap.html" target="_blank"&gt;Hashmap&lt;/a&gt; is a data structure that holds “key value” pairs. It has a constant time, or &lt;a href="http://en.wikipedia.org/wiki/Big_O_notation" target="_blank"&gt;O(1)&lt;/a&gt; time requirement for retrieving an element from the array. This means that it takes the same time to pull any element from the array, regardless of the size. This is possible by using a hashing function, which generates the array indices, given the input key.&lt;/p&gt; &lt;p&gt;A Hashmap is used (in this case) to map Integer keys to an object. &lt;/p&gt; &lt;p align="center"&gt;&lt;em&gt;&lt;strong&gt;What is a SparseArray?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;To understand what a &lt;a href="http://en.wikipedia.org/wiki/Sparse_array" target="_blank"&gt;SparseArray&lt;/a&gt; is, it is helpful to understand how a standard array works. An array is really just a continuous block of memory. The size of this block corresponds to how many elements the array can hold. For example, if a object requires 10 bytes of storage, and the array is created that can hold 5 of these objects, then the array has 50 byte memory block. Each of the objects in the array is given a 10 byte segment. By using the array index, you are actually moving through the array’s memory, 10 bytes at a time.&lt;/p&gt; &lt;p&gt;A problem comes into play when you want specific indices to map to specific objects, and they don’t cover every indices. For example, if you want an object at indices 4 and 5, but you don’t care about indices 1, 2, or 3, then you wind up wasting memory with an array.&lt;/p&gt; &lt;p align="center"&gt;&lt;em&gt;&lt;strong&gt;Why use a SparseArray over a Hashmap?&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt; &lt;p&gt;It seems that the SparseArray is a more efficient solution than using a Hashmap to map Integers to objects. The theory is that the SparseArray can add and retrieve elements quicker than a HashMap, in this case, by removing the hashing function processing time.&lt;/p&gt; &lt;p&gt;As you can see from the SparseArray page, and the Lint warning, the statements here are pretty vague. &lt;/p&gt; &lt;p&gt;&lt;em&gt;Is a SparseArray better than a Hashmap all the time? If not, when does a HashMap become more efficient than the SparseArray?&lt;/em&gt;&lt;/p&gt; &lt;h2&gt;The Experiment&lt;/h2&gt; &lt;p&gt;To compare the two&amp;nbsp; data structures, I designed a quick and simple test (and app). The bench marks gauge how long it takes to:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Insert x random values (with a range from 0 to y)  &lt;li&gt;Retrieve x random values (with a range from 0 to y) &lt;/li&gt;&lt;/ol&gt; &lt;p&gt;To handle this experiment, I wrote a simple Android app that contains a basic UI, and a few Async Tasks to do the above experiment (available on Github soon).&lt;/p&gt; &lt;p&gt;For the experiment, I tested two different variables:&lt;/p&gt; &lt;ol&gt; &lt;li&gt;The array size from 1, 10, 100,…, to 1,000,000  &lt;li&gt;The range of numbers within the array from 1, 10, 100, …, to 100,000,000&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;The app was run on a Samsung Galaxy 2 with Android version 2.3.4.&lt;/p&gt; &lt;h3&gt;Results&lt;/h3&gt; &lt;h2&gt;SparseArray Results&lt;/h2&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-CxR_t0aaMao/UAR5YIBWDtI/AAAAAAAABsw/3_LFnFzOPLk/s1600-h/image39.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-5x6KTtKTHDk/UAR5Y6xti-I/AAAAAAAABs4/4BZ-7U9WgtU/image_thumb21.png?imgmax=800" width="454" height="275"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-fc0T_9SOeL0/UAR5ZcCFbBI/AAAAAAAABtA/ME9SOCK3a00/s1600-h/image44.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-yHZQZ98fUUE/UAR5ZzLcJ1I/AAAAAAAABtI/K4KTFe9ALbc/image_thumb24.png?imgmax=800" width="454" height="276"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;The SparseArray is a very quick data structure for sizes of 10,000 and less. If you are pulling data from your array considerably more than adding to it, you can get away with a size of 100,000. It starts to slow down a bit with the jump to 1,000, but nothing too surprising. &lt;/p&gt; &lt;h2&gt;Hashmap Results&lt;/h2&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-c2h2UQPTptE/UAR5aTxxNrI/AAAAAAAABtQ/fsm1FAYAdiU/s1600-h/image55.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-9yLpezOSkqk/UAR5a5FZToI/AAAAAAAABtY/bm_qls-zDdQ/image_thumb29.png?imgmax=800" width="454" height="276"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh5.ggpht.com/--NWPJSIL96s/UAR5bR07uKI/AAAAAAAABtg/9dtPNiqgXFw/s1600-h/image3.png"&gt;&lt;img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-bgKRmVaSrSY/UAR5cQ1FfmI/AAAAAAAABto/olDBwexTHUI/image_thumb1.png?imgmax=800" width="454" height="276"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;The Executive Summary&lt;/h2&gt; &lt;p&gt;The Hashmap and the SparseArray have very comparable performance up to the 10,000 size mark. The 100,000 size mark is where some interesting results are found. For retrieving elements within a 100,000 size array, performance deteriorates quickly once the range of integers exceeds 1,000.&lt;/p&gt; &lt;p&gt;So it seems the Hashmap and the SparseArray are very similar for data structure sizes under 1,000, with any range you would like. &lt;em&gt;The performance gains at a size of 1,000 would likely be very small, if any.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Both data structures have difference performances when the size has been increased to the 10,000 mark. At this level (in yellow in the above graphs), t&lt;em&gt;he Hashmap has greater performance with adding objects, while the SparseArray has greater performance when retrieving objects.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;At a size of 100,000 (in red in the above graphs), the Hashmap loses performance very quickly, at the 100 range mark. &lt;em&gt;However the SpraseArray is still able to retrieve elements in this range with comparable efficiency&lt;/em&gt;. It also breaks down after the 1,000 range limit has been hit through.&lt;/p&gt; &lt;p&gt;So with all the fun stuff above, I walk away with a few new theories:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;In Android (and mobile programming in general) having more than 10,000 objects in a data structure in memory seems to be an upper limit.  &lt;li&gt;For smaller arrays (under 1,000) the performance of the SparseArray and the Hashmap are very comparable  &lt;li&gt;For arrays larger than 10,000, if you are adding more than retrieving elements, try the SparseArray.  &lt;li&gt;For arrays larger than 100,000, give the SparseArray a shot… or fix your application design so you don’t have any insanely large in-memory data structures.&lt;/li&gt;&lt;/ul&gt;  &lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/G5rd1DwjNGg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/9177608662851588923/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/07/android-performance-tweaking-parsearray.html#comment-form" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/9177608662851588923?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/9177608662851588923?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/G5rd1DwjNGg/android-performance-tweaking-parsearray.html" title="Android Performance Tweaking: ParseArray Versus Hashmap" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh5.ggpht.com/-5x6KTtKTHDk/UAR5Y6xti-I/AAAAAAAABs4/4BZ-7U9WgtU/s72-c/image_thumb21.png?imgmax=800" height="72" width="72" /><thr:total>3</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/07/android-performance-tweaking-parsearray.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUIGQX88eCp7ImA9WhJREU4.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-4124877935597696623</id><published>2012-07-12T09:54:00.001-04:00</published><updated>2012-07-12T18:52:00.170-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-12T18:52:00.170-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="I/O" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="Google" /><title>Google IO 2012 Session Videos are Up</title><content type="html">&lt;p&gt;Now that this year’s &lt;a href="https://developers.google.com/events/io/" target="_blank"&gt;Google I/O&lt;/a&gt; is over, all of the sessions have be uploaded to &lt;a href="http://www.youtube.com/playlist?list=PL4C6BCDE45E05F49E" target="_blank" &gt;YouTube&lt;/a&gt;. This year we have 28 videos, each of them about an hour long. I highly recommend checking out at least a few of them.&lt;/p&gt; &lt;p&gt;Time to start watching.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/DZXY1Lp1Fa4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/4124877935597696623/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/07/google-io-2012-session-videos-are-up.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/4124877935597696623?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/4124877935597696623?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/DZXY1Lp1Fa4/google-io-2012-session-videos-are-up.html" title="Google IO 2012 Session Videos are Up" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/07/google-io-2012-session-videos-are-up.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkACQ38zeCp7ImA9WhJSGEo.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-3841974916024198897</id><published>2012-07-09T17:51:00.001-04:00</published><updated>2012-07-09T17:52:42.180-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-09T17:52:42.180-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="Apple" /><category scheme="http://www.blogger.com/atom/ns#" term="Python" /><title>Python Is Out For IOS</title><content type="html">&lt;p&gt;It looks like Python is the way to go if you want to use a scripting language in the mobile world. &lt;a href="http://itunes.apple.com/app/python-for-ios/id485729872?mt=8"&gt;Python&lt;/a&gt; is out for iOS now, although its not free. It looks like it is a bit further along and more polished than the &lt;a href="http://code.google.com/p/python-for-android/"&gt;Android version&lt;/a&gt; Google has been working on for awhile now. Writing apps in Python over Java or Objective-C would make life much easier. I guess well see how bad the performance hit for using a scripting language in the mobile world is soon.&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/-UvlF0aBMoI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/3841974916024198897/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/07/python-is-out-for-ios.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3841974916024198897?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/3841974916024198897?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/-UvlF0aBMoI/python-is-out-for-ios.html" title="Python Is Out For IOS" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/07/python-is-out-for-ios.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIFRX08cCp7ImA9WhJTFkg.&quot;"><id>tag:blogger.com,1999:blog-2704071337043425901.post-8272604583049752365</id><published>2012-06-25T16:01:00.001-04:00</published><updated>2012-06-25T16:01:54.378-04:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-25T16:01:54.378-04:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="performance" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="development" /><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><category scheme="http://www.blogger.com/atom/ns#" term="web" /><title>JSON versus XML: Is JSON Really Better than XML?–Here’s the Code</title><content type="html">&lt;p&gt;The code used to test the performance of JSON and XML is now available on &lt;a href="https://github.com/ProMobile/Xml-Versus-JSON"&gt;GitHub&lt;/a&gt;. For more info, check out my last post: &lt;a href="http://www.programmingmobile.com/2012/06/json-versus-xml-is-json-really-better.html"&gt;JSON versus XML: is JSON Really Better Than XML?&lt;/a&gt;&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/programmingmobile/sKjg/~4/usLKffTTBGo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.programmingmobile.com/feeds/8272604583049752365/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.programmingmobile.com/2012/06/json-versus-xml-is-json-really-better_25.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/8272604583049752365?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/2704071337043425901/posts/default/8272604583049752365?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/programmingmobile/sKjg/~3/usLKffTTBGo/json-versus-xml-is-json-really-better_25.html" title="JSON versus XML: Is JSON Really Better than XML?–Here’s the Code" /><author><name>Isaac</name><uri>http://www.blogger.com/profile/00353767501461962730</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.programmingmobile.com/2012/06/json-versus-xml-is-json-really-better_25.html</feedburner:origLink></entry></feed>
