<?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;CEQMRX87fCp7ImA9WhBVEkg.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789</id><updated>2013-04-18T10:33:04.104+08:00</updated><category term="Screen Brightness" /><category term="Activity" /><category term="AbsoluteLayout" /><category term="HorizontalScrollView" /><category term="Google Maps" /><category term="Picture" /><category term="reflection" /><category term="XmlPullParser" /><category term="Notification" /><category term="debugging" /><category term="RadioButton" /><category term="ListActivity" /><category term="MediaStore" /><category term="Google TV" /><category term="ACCESS_NETWORK_STATE" /><category term="Custom Adapter" /><category term="AppEngine" /><category term="Bitmap" /><category term="My Battery Status" /><category term="RadioGroup" /><category term="Announcement" /><category term="SetContentView" /><category term="Programming" /><category term="Speak Up" /><category term="BroadcastReceiver" /><category term="Environment" /><category term="Internal class" /><category term="VIBRATE" /><category term="Ubuntu 9.04" /><category term="WebView" /><category term="AlertDialog" /><category term="Default Fonts" /><category term="Drawing" /><category term="Mobile App Contests" /><category term="GestureDetector" /><category term="Shoot and Learn" /><category term="ACCESS_FINE_LOCATION" /><category term="Android" /><category term="Design Patterns" /><category term="Handler" /><category term="InputFilter" /><category term="Gallery" /><category term="SpeakUp" /><category term="Adobe Air" /><category term="Android Tool" /><category term="Intent" /><category term="TableLayout" /><category term="TabWidget" /><category term="MediaPlayer" /><category term="TextToSpeech" /><category term="GridView" /><category term="HttpPost" /><category term="RelativeLayout" /><category term="Localization" /><category term="Log Collector" /><category term="Contacts" /><category term="Restart App" /><category term="Google" /><category term="Options Menu" /><category term="Android Video" /><category term="sdcard" /><category term="Android Future" /><category term="Canvas" /><category term="Content Provider" /><category term="App Inventor" /><category term="View Group" /><category term="View" /><category term="LinearLayout" /><category term="IntelliJ" /><category term="Layout" /><category term="RECEIVE_BOOT_COMPLETED" /><category term="StorageState" /><category term="mac" /><category term="Wifi" /><category term="Audio files" /><category term="Hardware" /><category term="EditText" /><category term="ACCESS_COARSE_LOCATION" /><category term="android x86" /><category term="Battery" /><category term="Contact" /><category term="ACCESS_WIFI_STATE" /><title>Tutorial For Android</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.tutorialforandroid.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>103</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/TutorialForAndroid" /><feedburner:info uri="tutorialforandroid" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;C0IFSXw4fCp7ImA9WhNVFkk.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-7673901691668525474</id><published>2012-12-28T04:51:00.001+08:00</published><updated>2012-12-28T04:51:58.234+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-28T04:51:58.234+08:00</app:edited><title>Card Camera App</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Releasing our newest android app &lt;a href="https://play.google.com/store/apps/details?id=com.ramentech.cardcamera.free"&gt;https://play.google.com/store/apps/details?id=com.ramentech.cardcamera.free&lt;/a&gt; with this app you could create cards (currently magic cards) and share to your friends.
&lt;br /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/7673901691668525474/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=7673901691668525474" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/7673901691668525474?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/7673901691668525474?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/vU0inzgcgmM/card-camera-app.html" title="Card Camera App" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2012/12/card-camera-app.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkICR3kyfCp7ImA9WhNTFks.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-2077339418530367487</id><published>2012-10-19T23:29:00.000+08:00</published><updated>2012-10-19T23:29:26.794+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-19T23:29:26.794+08:00</app:edited><title>Giving away free nexus 7</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Over at &lt;a href="http://www.upick.in"&gt;uPick.in&lt;/a&gt; we are giving away a free Nexus 7 :) or an Ipod Touch if like IOS. We need to reach 10000 votes for us to get the item shipped. &lt;br /&gt;
Go vote and share this link &lt;a href="http://www.upick.in/u/FIj"&gt;Free Nexus 7/IPod Touch&lt;/a&gt;&lt;br /&gt;
Thanks everyone
&lt;br /&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/2077339418530367487/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=2077339418530367487" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/2077339418530367487?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/2077339418530367487?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/W-TPmBSKG4s/giving-away-free-nexus-7.html" title="Giving away free nexus 7" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2012/10/giving-away-free-nexus-7.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C04MQXs9eyp7ImA9WhNTE0k.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-5039964127129223182</id><published>2012-10-16T06:59:00.001+08:00</published><updated>2012-10-16T06:59:40.563+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-16T06:59:40.563+08:00</app:edited><title>Introducing uPick.In</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
As you may have figured out i havent post in a while, have been so busy with work and into a new venture after work.
&lt;br /&gt; Here is the part i introduce &lt;a href="http://www.upick.in"&gt;uPick.In&lt;/a&gt; while its not Android related (it will in the future :]) It would be what i would be busy with in the following months. &lt;a href="http://www.upick.in"&gt;uPick.In&lt;/a&gt; is our vision of what a poll/voting site should be in our day and age where we include sentence based poll (create a poll in sentence style) and a gallery poll (poll with external links) and more to come in the future :] 
&lt;br /&gt;&lt;br /&gt;
Here is an example of how to create a poll
&lt;iframe width="560" height="315" src="http://www.youtube.com/embed/axP2JXpNR18" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
&lt;br /&gt;&lt;br /&gt;
If you have any suggestions or any comments with it, just drop it over at the comment page here or create a poll in &lt;a href="http://www.upick.in/upick"&gt;http://www.upick.in/upick&lt;/a&gt; &lt;br /&gt;Thanks everyone
&lt;br /&gt;
&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/5039964127129223182/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=5039964127129223182" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5039964127129223182?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5039964127129223182?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/ehJQQSgPizM/introducing-upickin.html" title="Introducing uPick.In" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://img.youtube.com/vi/axP2JXpNR18/default.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2012/10/introducing-upickin.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0IGQ349eCp7ImA9WhJTFkg.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-1468493542431856304</id><published>2012-06-26T05:25:00.000+08:00</published><updated>2012-06-26T05:25:22.060+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-26T05:25:22.060+08:00</app:edited><title>Google IO 2012</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Within 2 days, Google IO would be live. Here is widget that would stream the developer conference.&lt;br /&gt;&lt;br /&gt;
&lt;div align="center"&gt;
&lt;iframe src="https://developers.google.com/events/announce/googleio2012/?announcements=on&amp;feedheight=300&amp;barcolor=%233D88F3&amp;linkcolor=%23205AAF&amp;width=480&amp;height=320" style="border:0;box-shadow:0 0px 20px #888;-webkit-box-shadow:0 0px 20px #888;-khtml-box-shadow:0 0px 20px #888;-moz-box-shadow:0 0px 20px #888;-ms-box-shadow:0 0px 20px #888;-o-box-shadow:0 0px 20px #888;width:480px;height:620px"&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/1468493542431856304/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=1468493542431856304" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/1468493542431856304?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/1468493542431856304?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/K-DSWVkdgO0/google-io-2012.html" title="Google IO 2012" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2012/06/google-io-2012.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8AQnczeSp7ImA9WhJTFUg.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-2945781031960247877</id><published>2012-06-25T00:54:00.000+08:00</published><updated>2012-06-25T00:54:03.981+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-25T00:54:03.981+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="TabWidget" /><category scheme="http://www.blogger.com/atom/ns#" term="HorizontalScrollView" /><title>Center Tab Item in TabWidget and HorizontalScrollView in Android</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;So you have a TabWidget within HorizontalScrollView, and you want to center the selectedTab (either dynamically or if you have ViewPager on page scroll). On your TabHost, you'll have something like this.
 
&lt;pre name="code" class="xml"&gt;&amp;lt;HorizontalScrollView
        android:id="@+id/horizontalScrollView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true"
        android:scrollbars="none"
        android:layout_weight="0"
        &gt;

    &amp;lt;TabWidget
            android:id="@android:id/tabs"
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"

            /&gt;
&amp;lt;/HorizontalScrollView&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;On your activity/fragment
&lt;pre name="code" class="java"&gt;public void centerTabItem(int position) {
    tabHost.setCurrentTab(position);
    final TabWidget tabWidget = tabHost.getTabWidget();
    final int screenWidth = getWindowManager().getDefaultDisplay().getWidth();
    final int leftX = tabWidget.getChildAt(position).getLeft();
    int newX = 0;

    newX = leftX + (tabWidget.getChildAt(position).getWidth() / 2) - (screenWidth / 2);
    if (newX &lt; 0) {
        newX = 0;
    }
    horizontalScrollView.scrollTo(newX, 0);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
Say you have a viewPager, then you could use it like
&lt;pre name="code" class="java"&gt;public void onPageSelected(int position) {
    centerTabItem(position);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;strong style="font-size:110%"&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;i style="color:#777"&gt;final int screenWidth = getWindowManager().getDefaultDisplay().getWidth();&lt;/i&gt;&lt;br /&gt;
Get the phone's width, we need to to know where the center is (by dividing it by half)
&lt;br /&gt;&lt;br /&gt;
&lt;i style="color:#777"&gt;final int leftX = tabWidget.getChildAt(position).getLeft();&lt;/i&gt;&lt;br/&gt;
Get the x position of the item we want to center, this is relative to its parent (horizontalScrollView)&lt;Br /&gt;&lt;br /&gt;
&lt;i style="color:#777"&gt;newX = leftX + (tabWidget.getChildAt(position).getWidth() / 2) - (screenWidth / 2);&lt;/i&gt;&lt;br /&gt;
The center would be calculated based on horizontalScrollView.scrollTo, so the left x plus half the item width, would be negative value as the new x would scroll to the left of the parent, then if you minus (or plus since its going to the left plane/negative) to the half width value of the device then you will arrive in the center.
&lt;br /&gt;&lt;br /&gt;
&lt;i style="color:#777"&gt;horizontalScrollView.scrollTo(newX, 0);&lt;/i&gt;&lt;br /&gt;
Scroll the tabWidget to the newX, y stays at 0
&lt;/div&gt;

&lt;div&gt;Hope this helps :)&lt;/div&gt;

&lt;/div&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/2945781031960247877/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=2945781031960247877" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/2945781031960247877?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/2945781031960247877?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/6k6BTvXeSCk/center-tab-item-in-tabwidget-and.html" title="Center Tab Item in TabWidget and HorizontalScrollView in Android" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2012/06/center-tab-item-in-tabwidget-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUNQX85cCp7ImA9WhRVF0s.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-5008051366415388278</id><published>2012-01-17T09:21:00.001+08:00</published><updated>2012-01-17T09:21:30.128+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-17T09:21:30.128+08:00</app:edited><title>Welcome 2012</title><content type="html">Belated happy new year, advance happy chinese new year. Last year, i was so preoccupied with a lot of stuff that i only blogged 6 times and only 1 of which is an android tutorial, this year it would definitely be more than 1 lol. And there are lots of great tutorial out there already and sites like &lt;a href="http://stackoverflow.com/questions/tagged/android"&gt;Stackoverlow&lt;/a&gt; is great place to ask questions. Towards the end of the year last year, i created  &lt;a href="http://www.generateandroidcode.com/"&gt;Generate Android Code&lt;/a&gt; to do some code generator, you guys check it out once in awhile.
&lt;Br /&gt;
To start this year, i cleaned up this blog's links and image links that linked to the wordpress version of this site :)</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/5008051366415388278/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=5008051366415388278" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5008051366415388278?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5008051366415388278?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/_eVZuq8Z3-A/welcome-2012.html" title="Welcome 2012" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2012/01/welcome-2012.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0AFRnkzfSp7ImA9WhRRGUQ.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-2878561238999482384</id><published>2011-12-04T19:54:00.001+08:00</published><updated>2011-12-04T19:55:17.785+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-04T19:55:17.785+08:00</app:edited><title>Going to ADL HK :)</title><content type="html">This year, like last year, i have a chance to go to Android Developer Labs on Dec 6, i hope i learn more about android and how to code in tablets :) Anyone going?</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/2878561238999482384/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=2878561238999482384" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/2878561238999482384?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/2878561238999482384?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/cbc9XFnZUD8/going-to-adl-hk.html" title="Going to ADL HK :)" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2011/12/going-to-adl-hk.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8BQXo5eCp7ImA9WhVREkU.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-801157806649371059</id><published>2011-06-20T05:30:00.000+08:00</published><updated>2012-03-21T06:34:10.420+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-21T06:34:10.420+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Android Tool" /><category scheme="http://www.blogger.com/atom/ns#" term="Content Provider" /><title>Create Content Provider - Android Tool</title><content type="html">Over at monmonja.com i created another tool (which i use most, so the generated code might make sense more to me) and its a tool to create content provider, the generated content provider class is one of the my oldest code structure which if someone knows a better way to do it then feel free to comment below and remember its an alpha tool so there might be some bugs on it.&lt;br /&gt;
&lt;br /&gt;
Anyway without further talk, here is the link &lt;br /&gt;
&lt;a href="http://www.generateandroidcode.com/android/contentProvider" target="_blank"&gt;&lt;strong&gt;http://www.generateandroidcode.com/android/contentProvider&lt;/strong&gt;&lt;/a&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/801157806649371059/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=801157806649371059" title="7 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/801157806649371059?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/801157806649371059?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/yHKC08itzyo/create-content-provider-android-tool.html" title="Create Content Provider - Android Tool" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>7</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2011/06/create-content-provider-android-tool.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk8HQXc6eyp7ImA9WhZUGEo.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-6986887738094815343</id><published>2011-06-12T18:33:00.002+08:00</published><updated>2011-06-12T18:33:50.913+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-12T18:33:50.913+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Android" /><title>Making Android tools</title><content type="html">Over at monmonja.com i'm completely rewriting the whole site with tools i use and the first tool is for Android. &lt;a href="http://www.monmonja.com/android/alert"&gt;Making AlertDialog&lt;/a&gt; Check it out (Tested in Chrome, should work in Firefox, dont care about IE)</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/6986887738094815343/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=6986887738094815343" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/6986887738094815343?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/6986887738094815343?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/BgEeomxHC28/making-android-tools.html" title="Making Android tools" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2011/06/making-android-tools.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUECRnozcSp7ImA9WhZRGUo.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-1355148488388074045</id><published>2011-04-17T01:06:00.002+08:00</published><updated>2011-04-17T01:07:47.489+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-17T01:07:47.489+08:00</app:edited><title>Testing Honeycomb</title><content type="html">Lately there had been news that there were only few (100 or else) native honeycomb apps and there were only 100k or less Motorola Xoom released so far. Thanks to Google for not playing nice to the devs (remember G1 dev phone? where is our dev tablet?)&lt;br /&gt;
&lt;br /&gt;
I still love Android but this is madness, first Xoom is only released on few countries (US and Canada, and ?) the rest of the developers on the world are treated like they dont exist, this was okay with G1/Android 1.0 but i mean its Android 3.0 and there are tones of good developers outside these countries that is waiting to bring their app to tablet form.&lt;br /&gt;
&lt;br /&gt;
Wait there's the emulator, the emulator is so slow (did adjust the memory, heapsize, launched at terminal) but its just not fun working on it.&lt;br /&gt;
&lt;br /&gt;
So now i'll wait for a honeycomb tablet to release here in Hong Kong (probably ill get an asus eee transformer) before i continue with my android stuff. Probably ill just do some node.js or php zend stuff in the meanwhile. &lt;br /&gt;
&lt;br /&gt;
To end this, the number of apps released for the honeycomb tablets vs the days honeycomb is released (in numbers) is just so bad. Google should call the devs to help them like they did with Android 1.0 then alienating them.</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/1355148488388074045/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=1355148488388074045" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/1355148488388074045?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/1355148488388074045?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/ChG2BJmQ_a8/testing-honeycomb.html" title="Testing Honeycomb" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2011/04/testing-honeycomb.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU4BR3o4cCp7ImA9WhZSEk8.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-7558903366271886159</id><published>2011-03-27T19:05:00.000+08:00</published><updated>2011-03-27T19:05:56.438+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-03-27T19:05:56.438+08:00</app:edited><title>New work next month - healthguru.com</title><content type="html">I firstly apologies for not I havent post for a while (3 months) and i havent answer any of the questions on my comments and i have some articles that requires an update, one reason is that i have been having some side projects on backend stuff.&lt;br /&gt;
&lt;br /&gt;
Anyhow next month ill be joining &lt;a href="http://www.healthguru.com"&gt;http://www.healthguru.com&lt;/a&gt; doing some php stuff. I believe i'll have more free time when i start my new job for i will work remotely therefore ill try to work on this blog and android stuff and hope i could blog more articles, answer the questions soon, and update some old articles.&lt;br /&gt;
&lt;br /&gt;
In my pipeline:&lt;br /&gt;
Shoot &amp; Learn tablet version (i stopped the update of the phone version for now)&lt;br /&gt;
A drawing app that reflects the drawing tutorials i have on the site&lt;br /&gt;
Expends the language translate tool in  most of my app&lt;br /&gt;
Probably start to create a game?&lt;br /&gt;
&lt;br /&gt;
Thats all my goal in 2011. Thanks.</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/7558903366271886159/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=7558903366271886159" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/7558903366271886159?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/7558903366271886159?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/gyDrS_0U6YU/new-work-next-month-healthgurucom.html" title="New work next month - healthguru.com" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2011/03/new-work-next-month-healthgurucom.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEMMQHo7fip7ImA9WhZbEEs.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-8999182686554147008</id><published>2011-01-06T22:52:00.001+08:00</published><updated>2011-06-14T22:41:21.406+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-14T22:41:21.406+08:00</app:edited><title>Opening an Activity with string in Android</title><content type="html">This question has been asked here &lt;a href="http://stackoverflow.com/questions/2387139"&gt;http://stackoverflow.com/questions/2387139&lt;/a&gt; and &lt;a href="http://stackoverflow.com/questions/2184226/how-to-use-variable-while-calling-new-activity-in-intent"&gt;http://stackoverflow.com/questions/2184226/how-to-use-variable-while-calling-new-activity-in-intent&lt;/a&gt; and my problem is similar but i cant see the destination classes coz the classes are from different libraries and therefore i need to open an activity based on just the string and here is how i fixed mine:&lt;br /&gt;
&lt;br /&gt;
&lt;pre name="code" class="java"&gt;try {
&amp;nbsp; String className = 'com.almondmendoza.library.openActivity';
&amp;nbsp; Intent openNewIntent = new Intent( this, Class.forName( className ) );
&amp;nbsp; startActivity(  openNewIntent );
} catch (ClassNotFoundException e) {
&amp;nbsp; e.printStackTrace();  
}&lt;/pre&gt;&lt;br /&gt;
&lt;strong&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
Here we use &lt;a href="http://java.sun.com/developer/technicalArticles/ALT/Reflection/"&gt;reflections&lt;/a&gt; and just convert our class name to a class object.&lt;br /&gt;
&lt;br /&gt;
If you are interested in reflection we had blogged about it previously &lt;a href="http://www.tutorialforandroid.com/2010/07/access-internal-classes-in-android.html"&gt;Access internal classes in Android&lt;/a&gt; and &lt;a href="http://www.tutorialforandroid.com/2009/11/calling-private-methods-in-android.html"&gt;Calling Private Methods in Android&lt;/a&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/8999182686554147008/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=8999182686554147008" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/8999182686554147008?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/8999182686554147008?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/i_a5Pfpk68o/opening-activity-with-string-in-android.html" title="Opening an Activity with string in Android" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2011/01/opening-activity-with-string-in-android.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcFRn47eCp7ImA9Wx9QEkU.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-8324259791134413916</id><published>2010-12-25T22:40:00.000+08:00</published><updated>2010-12-25T22:40:17.000+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-25T22:40:17.000+08:00</app:edited><title>Merry Christmas, Happy New Year, Android 2010, Android 2011</title><content type="html">First of all Merry Christmas, and i'll be going into hibernation mode until the new year comes so Happy New Year as well :)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Android in 2010&lt;/b&gt;&lt;br /&gt;
* Our little green friend has been on its way to world domination, we just launch a new one into the outer space (Which later would be known as the origin of the terminators)&lt;br /&gt;
* Android is found in multiple devices, from Phones, to Tablets (Galaxy Tab having 10M sold), to Google TV (my sister in US got me one :-] ), and a lot more&lt;br /&gt;
* Froyo &amp; Gingerbread released, Market got its much awaited update, rooting/custom roms/xda are still strong and awesome&lt;br /&gt;
* People still call upon fragmentation on Android, yes it is but i would say its just fragmented between low end device and high end device which is better then the linux/unix fragmentation, and unless you're a game programmer the chances you would get this hardcore fragmentation is really less.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Our Site&lt;/b&gt;&lt;br /&gt;
* This year has been a slow year for TutorialForAndroid.com and i hope i could make more tutorials next year&lt;br /&gt;
* Last year i shown i was doing something that could build android app easier, I announced it way too early and then Google created App Creator (I suggest everyone to give it a try), and i stopped the development and move on with something else like ShootAndLearn app&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Android 2011&lt;/b&gt;&lt;br /&gt;
* Android would penetrate more market with Google TV having its app features, Tablets popping out left and right, PSP2 capturing the gaming community&lt;br /&gt;
* Android would not slow down its development, release often is better to push technology forward and Android is still young and evolving&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Quick Prediction on the future of Android (2011 and beyond)&lt;br /&gt;
* Finally i'll work for Google (ahahha) or be an Android programmer (I love WebProgramming too especially frontend technology like Javascript,Actionscript and CSS, yes Android is also frontend)&lt;br /&gt;
* PS4 would be announced as Google TV with PS and PSN&lt;br /&gt;
* Android would benefit from Chrome OS and vice versa (More apps would be web centric via webview)&lt;br /&gt;
* Java would not be the only language you can code Android with (currently you could do it) but future would be better (Javascript, Python or Ruby please)&lt;br /&gt;
* Android ndk would/should be married to Google Native Client (used in Chrome)&lt;br /&gt;
* O3D, WebGL, more HTML5 features to include in future version of Android &lt;br /&gt;
* Android would have WAC/Bondi features where you could call native functions from any website given you would grant them permission, Chrome OS might be the first to try this&lt;br /&gt;
&lt;br /&gt;
As you can see most of my prediction expect PS4 is actually Android meeting Chrome OS, like what  Eric Schmidt stated Android would eventually marry Chrome OS (Android 5.0?), this might not happen in 1 year time but most of the technologies between them are just overlapping each other and it make sense for them to meet later on (currently its still not ideal for it to happen).&lt;br /&gt;
&lt;br /&gt;
To conclude our green friend has and would remain strong and I here would try to help more friends to get into the green robot army :) Merry Christmas and Happy New year to all of you</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/8324259791134413916/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=8324259791134413916" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/8324259791134413916?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/8324259791134413916?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/ybJJ3lJd97c/merry-christmas-happy-new-year-android.html" title="Merry Christmas, Happy New Year, Android 2010, Android 2011" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/12/merry-christmas-happy-new-year-android.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkIDQnc4fSp7ImA9Wx9RE0k.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-959912362528810429</id><published>2010-12-14T23:29:00.000+08:00</published><updated>2010-12-14T23:29:33.935+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-14T23:29:33.935+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Drawing" /><category scheme="http://www.blogger.com/atom/ns#" term="Canvas" /><title>Previewing while Drawing with Canvas in Android</title><content type="html">After my site being gone from the web yesterday, its back :) it happens to be a blogger bug. Anyway i got a lot of request on how to preview your drawing, and continue our &lt;a href="http://www.tutorialforandroid.com/p/drawing-with-canvas-series.html"&gt;Drawing with Canvas&lt;/a&gt; series, here is how to preview while drawing.&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Notes&lt;/strong&gt;&lt;br /&gt;
&amp;bull; The files are uploaded in &lt;a href="http://goo.gl/ecHpE"&gt;http://goo.gl/ecHpE&lt;/a&gt;&lt;br /&gt;
&amp;bull; The project was build in IntelliJ and it should be easy to import to Eclipse&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;What Do I Need&lt;/strong&gt;&lt;br /&gt;
DrawingSurface&lt;br /&gt;
&lt;code&gt;public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback {&lt;br /&gt;
&amp;nbsp; public boolean isDrawing = true;&lt;br /&gt;
&amp;nbsp; public DrawingPath previewPath;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; private Handler previewDoneHandler = new Handler(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public void handleMessage(Message msg) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; isDrawing = false;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; };&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; class DrawThread extends  Thread{&lt;br /&gt;
&amp;nbsp; &amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public void run() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; commandManager.executeAll(c,previewDoneHandler);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; previewPath.draw(c);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; };&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Drawing Activity&lt;br /&gt;
&lt;code&gt;public class DrawingActivity extends Activity implements View.OnTouchListener{&lt;br /&gt;
&amp;nbsp; public void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; drawingSurface.previewPath = new DrawingPath();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; drawingSurface.previewPath.path = new Path();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; drawingSurface.previewPath.paint = getPreviewPaint();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ...&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; private Paint getPreviewPaint(){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; final Paint previewPaint = new Paint();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; previewPaint.setColor(0xFFC1C1C1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; previewPaint.setStyle(Paint.Style.STROKE);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; previewPaint.setStrokeJoin(Paint.Join.ROUND);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; previewPaint.setStrokeCap(Paint.Cap.ROUND);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; previewPaint.setStrokeWidth(3);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return previewPaint;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; public boolean onTouch(View view, MotionEvent motionEvent) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush.mouseDown(drawingSurface.previewPath.path, motionEvent.getX(), motionEvent.getY());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush.mouseMove(drawingSurface.previewPath.path, motionEvent.getX(), motionEvent.getY());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_UP){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush.mouseUp(drawingSurface.previewPath.path, motionEvent.getX(), motionEvent.getY());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; drawingSurface.previewPath.path = new Path();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Quick Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;div class="amazonAssociates" style="float: right; width:130px"&gt;Ads from Amazon: &lt;iframe src="http://rcm.amazon.com/e/cm?t=monmonja05-20&amp;o=1&amp;p=8&amp;l=bpl&amp;asins=1430230002&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="align:left;padding-top:5px;width:131px;height:245px;padding-right:10px;"align="left" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;strong style="font-size: 110%;"&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public boolean isDrawing = true;&lt;/i&gt;&lt;br /&gt;
Lets introduce something that would tell our app if we are drawing or not.&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public DrawingPath previewPath;&lt;/i&gt;&lt;br /&gt;
Here we create another DrawingPath which would only do the preview for us&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;private Handler previewDoneHandler = new Handler(){&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; public void handleMessage(Message msg) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; isDrawing = false;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
};&lt;/i&gt;&lt;br /&gt;
Here we create a handler to tell our app to stop drawing at the end of the last path it has drawn (this function should named differently, ahhah)&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;class DrawThread extends  Thread{&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; public void run() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; commandManager.executeAll(c,previewDoneHandler);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; previewPath.draw(c);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
};&lt;/i&gt;&lt;br /&gt;
Here you draw the preview path and pass our complete handler to stop our app from drawing over and over&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
&amp;nbsp; drawingSurface.previewPath = new DrawingPath();&lt;br /&gt;
&amp;nbsp; drawingSurface.previewPath.path = new Path();&lt;br /&gt;
&amp;nbsp; drawingSurface.previewPath.paint = getPreviewPaint();&lt;br /&gt;
&amp;nbsp; ...&lt;br /&gt;
private Paint getPreviewPaint(){&lt;br /&gt;
&amp;nbsp; ...&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
Here we just initialize the previewPath with a different path (a kinda gray paint, 0xFFC1C1C1)&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public boolean onTouch(View view, MotionEvent motionEvent) {&lt;br /&gt;
&amp;nbsp; if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){&lt;br /&gt;
nbsp; &amp;nbsp; currentBrush.mouseDown(drawingSurface.previewPath.path, motionEvent.getX(), motionEvent.getY());&lt;br /&gt;
&amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentBrush.mouseMove(drawingSurface.previewPath.path, motionEvent.getX(), motionEvent.getY());&lt;br /&gt;
&amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_UP){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentBrush.mouseUp(drawingSurface.previewPath.path, motionEvent.getX(), motionEvent.getY());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; drawingSurface.previewPath.path = new Path();&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
Here we use the concept we understood from brushes &lt;a href="http://www.tutorialforandroid.com/2010/12/drawing-with-canvas-in-android-brushes.html"&gt;Read the explanation here&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Hope this helps :)</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/959912362528810429/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=959912362528810429" title="10 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/959912362528810429?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/959912362528810429?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/nUAA60FM8qA/previewing-while-drawing-with-canvas-in.html" title="Previewing while Drawing with Canvas in Android" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>10</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/12/previewing-while-drawing-with-canvas-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkUGRnY9eip7ImA9Wx9SF04.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-7449236921178055358</id><published>2010-12-08T00:10:00.000+08:00</published><updated>2010-12-08T00:10:27.862+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-08T00:10:27.862+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Drawing" /><category scheme="http://www.blogger.com/atom/ns#" term="Canvas" /><title>Drawing with Canvas in Android, Brushes</title><content type="html">Continuing with our &lt;a href="http://www.tutorialforandroid.com/p/drawing-with-canvas-series.html"&gt;Drawing in Canvas series&lt;/a&gt;, let us see how to implement brushes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Introduction&lt;/strong&gt;&lt;br /&gt;
Drawing lines is boring, lets draw something else&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Notes&lt;/strong&gt;&lt;br /&gt;
&amp;bull; We would introduce a new package com.almondmendoza.drawings.brush&lt;br /&gt;
&amp;bull; The files are uploaded in &lt;a href="http://goo.gl/ecHpE"&gt;http://goo.gl/ecHpE&lt;/a&gt;&lt;br /&gt;
&amp;bull; The project was build in IntelliJ and it should be easy to import to Eclipse&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;What Do I Need&lt;/strong&gt;&lt;br /&gt;
IBrush.java&lt;br /&gt;
&lt;code&gt;public interface IBrush {&lt;br /&gt;
&amp;nbsp; public void mouseDown( Path path, float x, float y);&lt;br /&gt;
&amp;nbsp; public void mouseMove( Path path, float x, float y);&lt;br /&gt;
&amp;nbsp; public void mouseUp( Path path, float x, float y);&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Brush.java&lt;br /&gt;
&lt;code&gt;public class Brush implements  IBrush {&lt;br /&gt;
&amp;nbsp; public void mouseDown(Path path, float x, float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; // add codes here if it would affect every brush&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; public void mouseMove(Path path, float x, float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; // add codes here if it would affect every brush&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; public void mouseUp(Path path, float x, float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; // add codes here if it would affect every brush&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pen.java&lt;br /&gt;
&lt;code&gt;public class PenBrush extends Brush{&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; public void mouseDown(Path path, float x, float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; path.moveTo( x, y );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; path.lineTo(x, y);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; public void mouseMove(Path path, float x, float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; path.lineTo( x, y );&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; public void mouseUp(Path path, float x, float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; path.lineTo( x, y );&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
CircleBrush.java&lt;br /&gt;
&lt;code&gt;public class CircleBrush extends Brush{&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; public void mouseMove(Path path, float x, float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; path.addCircle(x,y,10,Path.Direction.CW);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
DrawingActivity.java &lt;br /&gt;
&lt;code&gt;public class DrawingActivity extends Activity implements View.OnTouchListener{&lt;br /&gt;
&amp;nbsp; ...&lt;br /&gt;
&amp;nbsp; private Brush currentBrush;&lt;br /&gt;
&amp;nbsp; public void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ...&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentBrush = new PenBrush();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ...&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; public boolean onTouch(View view, MotionEvent motionEvent) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush.mouseDown(currentDrawingPath.path, motionEvent.getX(), motionEvent.getY());&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush.mouseMove( currentDrawingPath.path, motionEvent.getX(), motionEvent.getY() );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_UP){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush.mouseUp( currentDrawingPath.path, motionEvent.getX(), motionEvent.getY() );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; drawingSurface.isDrawing = true;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return true;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; public void onClick(View view){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; switch (view.getId()){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; ...&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; case R.id.circleBtn:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush = new CircleBrush();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; case R.id.pathBtn:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush = new PenBrush();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Quick Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;div class="amazonAssociates" style="float: right; width:130px"&gt;Ads from Amazon: &lt;iframe src="http://rcm.amazon.com/e/cm?t=monmonja05-20&amp;o=1&amp;p=8&amp;l=bpl&amp;asins=0321673352&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="align:left;padding-top:5px;width:131px;height:245px;padding-right:10px;"align="left" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;strong style="font-size: 110%;"&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public interface IBrush {&lt;br /&gt;
&amp;nbsp; public void mouseDown( Path path, float x, float y);&lt;br /&gt;
&amp;nbsp; public void mouseMove( Path path, float x, float y);&lt;br /&gt;
&amp;nbsp; public void mouseUp( Path path, float x, float y);&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
We begin by creating a brush interface so that our brushes would be united :)&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public class Brush implements  IBrush {&lt;br /&gt;
&amp;nbsp; ...&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
Our brush class would serve as base classes for our other brushes, here we can implement codes that would be shared across different brushes&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public class PenBrush extends Brush{ ... } &lt;/i&gt;&lt;br /&gt;
From our previous article from the series we had implemented these codes directly on onTouch function on DrawingActivity, here we just move it to its own Brush class.&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public class CircleBrush extends Brush{&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; public void mouseMove(Path path, float x, float y) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; path.addCircle(x,y,10,Path.Direction.CW);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
In here we only make use of the mouseMove of our Brush class, as you can see we have path.addCircle where we could make other brushes by changing this to other function or adding more then one path (For other shapes available kindly refer to the &lt;a href="http://developer.android.com/reference/android/graphics/Path.html"&gt;Path Reference&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public boolean onTouch(View view, MotionEvent motionEvent) {&lt;br /&gt;
&amp;nbsp; if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentBrush.mouseDown(currentDrawingPath.path, motionEvent.getX(), motionEvent.getY());&lt;br /&gt;
&amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentBrush.mouseMove( currentDrawingPath.path, motionEvent.getX(), motionEvent.getY() );&lt;br /&gt;
&amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_UP){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentBrush.mouseUp( currentDrawingPath.path, motionEvent.getX(), motionEvent.getY() );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; drawingSurface.isDrawing = true;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; return true;&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
We rewrote the function to use our brushes to do the paths so that we could change the brush and not care about this function.&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public void onClick(View view){&lt;br /&gt;
&amp;nbsp; switch (view.getId()){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ...&lt;br /&gt;
&amp;nbsp; &amp;nbsp; case R.id.circleBtn:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush = new CircleBrush();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; case R.id.pathBtn:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentBrush = new PenBrush();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
This is now we change brushes&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br /&gt;
To add new brushes, just create a new class that extends the Brush class.</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/7449236921178055358/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=7449236921178055358" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/7449236921178055358?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/7449236921178055358?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/wN3wmCZGA7Q/drawing-with-canvas-in-android-brushes.html" title="Drawing with Canvas in Android, Brushes" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/12/drawing-with-canvas-in-android-brushes.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcFR3kzfip7ImA9Wx9SFkg.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-6753261504088219148</id><published>2010-12-07T01:20:00.000+08:00</published><updated>2010-12-07T01:20:16.786+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-07T01:20:16.786+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="My Battery Status" /><title>My Battery Status 2.1.0</title><content type="html">Been fixing the UI part of My battery status for days, now its live, anyone can search them on the  market (search for com.almondmendoza.monBattery). Next article should be back to our series :)</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/6753261504088219148/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=6753261504088219148" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/6753261504088219148?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/6753261504088219148?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/0fPa1EWszPE/my-battery-status-210.html" title="My Battery Status 2.1.0" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/12/my-battery-status-210.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0IMRHk9eip7ImA9Wx9SE0Q.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-5333321910900553694</id><published>2010-12-03T23:53:00.000+08:00</published><updated>2010-12-03T23:53:05.762+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-03T23:53:05.762+08:00</app:edited><title>TutorialForAndroid first 1000 visit</title><content type="html">After 2-3 years of this site, I finally hit the 1000 visit one single day, which just means i'm atleast helping 1000 (if all reads the tutorial) or a lot of programmers to Android with these tutorials :)&lt;br /&gt;
 &lt;br /&gt;
I would like to thanks everyone, and as we go forward, i would like focus on making series (like the drawing series) and as a new step to this site and my career, im opening up suggestions on what i could blog thus making use of google moderator &lt;a href="http://www.google.com/moderator/#15/e=40510&amp;t=40510.40"&gt;http://www.google.com/moderator/#15/e=40510&amp;t=40510.40&lt;/a&gt;, anyone can suggest a topic (please be warned that i do need time to learn them as well and only after work)&lt;br /&gt;
&lt;br /&gt;
Thanks again</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/5333321910900553694/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=5333321910900553694" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5333321910900553694?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5333321910900553694?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/DuB4bslKk2c/tutorialforandroid-first-1000-visit.html" title="TutorialForAndroid first 1000 visit" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/12/tutorialforandroid-first-1000-visit.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUGQ3YycSp7ImA9Wx9TGEo.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-3350288275432262005</id><published>2010-11-28T00:10:00.000+08:00</published><updated>2010-11-28T00:10:22.899+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-28T00:10:22.899+08:00</app:edited><title>Soft Kitty - Non Android</title><content type="html">Once in a while i would post non-android article and here is one of them. &lt;br /&gt;
&lt;br /&gt;
Anyone watch the big bang theory must know this song, if not here is a video &lt;br /&gt;
&lt;object width="640" height="385"&gt;&lt;param name="movie" value="http://www.youtube.com/v/sIp77PUvLTE?fs=1&amp;amp;hl=en_US"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;param name="allowscriptaccess" value="always"&gt;&lt;/param&gt;&lt;embed src="http://www.youtube.com/v/sIp77PUvLTE?fs=1&amp;amp;hl=en_US" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;br /&gt;
&lt;br /&gt;
And here is a guitar tab, ahhah&lt;br /&gt;
2 or B |--8-5-5--6-3-3--1-3-5-6-8---8-5-5--6-3-3--1-3-1--|  (repeat nth times)&lt;br /&gt;
&lt;br /&gt;
:)</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/3350288275432262005/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=3350288275432262005" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/3350288275432262005?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/3350288275432262005?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/XVYEuLaYe0I/soft-kitty-non-android.html" title="Soft Kitty - Non Android" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/11/soft-kitty-non-android.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8MSHozcSp7ImA9Wx9TFkw.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-5897462506194409496</id><published>2010-11-25T01:13:00.001+08:00</published><updated>2010-11-25T01:14:49.489+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-11-25T01:14:49.489+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="IntelliJ" /><title>Using library with resources in IntelliJ and Android</title><content type="html">As my previous articles indicates, im coding more Android in IntelliJ then eclipse (main reason is that it will let you forget you have a mouse). For those new to IntelliJ, like me, here is how i set up the library in IntelliJ so that both resources and code could be used.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Notes&lt;/strong&gt;&lt;br /&gt;
&amp;bull; Im new to IntelliJ so if im doing something wrong, kindly comment below :)&lt;br /&gt;
&amp;bull; As of writing the resources between library cant be handle properly when compiled (you can still do the coding with it) thus we need the help of command line (ant install, adb install/uninstall), on the Bug tracker it was reported to be fine in nightly.&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;What Do I Need&lt;/strong&gt;&lt;br /&gt;
&amp;bull; As of now you need the EAP of &lt;a href="http://confluence.jetbrains.net/display/IDEADEV/IDEA+X+EAP"&gt;IntelliJ&lt;/a&gt;&lt;br /&gt;
&amp;bull; Lastest &lt;a href="http://developer.android.com/sdk/index.html"&gt;Android SDK &lt;/a&gt;&lt;br /&gt;
&amp;bull; You need to know how to &lt;a href="http://blogs.jetbrains.com/idea/2009/08/developing-android-applications-in-maia/"&gt;create a project&lt;/a&gt;&lt;br /&gt;
&amp;bull; You need to know how to &lt;a href="http://blogs.jetbrains.com/idea/2010/09/android-library-projects-support/"&gt;create a library&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Instruction&lt;/strong&gt;&lt;br /&gt;
1) Open your project's module settings&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://4.bp.blogspot.com/_jcJUn2Pvhc0/TO0-kRufzJI/AAAAAAAA_q4/C_L-YIPJt2Q/s1600/Screen%2Bshot%2B2010-11-24%2Bat%2B10.48.21%2BPM.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="259" width="320" src="http://4.bp.blogspot.com/_jcJUn2Pvhc0/TO0-kRufzJI/AAAAAAAA_q4/C_L-YIPJt2Q/s320/Screen%2Bshot%2B2010-11-24%2Bat%2B10.48.21%2BPM.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="clear: both;"&gt;2) In Modules, click the add new module (see image below) &lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_jcJUn2Pvhc0/TO0-laLgLYI/AAAAAAAA_rI/H3qUFCdCh4Q/s1600/Screen%2Bshot%2B2010-11-24%2Bat%2B10.47.33%2BPM.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="258" width="320" src="http://1.bp.blogspot.com/_jcJUn2Pvhc0/TO0-laLgLYI/AAAAAAAA_rI/H3qUFCdCh4Q/s320/Screen%2Bshot%2B2010-11-24%2Bat%2B10.47.33%2BPM.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both;"&gt;3) Select your library if you had previously created one&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_jcJUn2Pvhc0/TO0-lFQh6GI/AAAAAAAA_rA/Xo0zItu6zr4/s1600/Screen%2Bshot%2B2010-11-24%2Bat%2B10.47.47%2BPM.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="259" width="320" src="http://1.bp.blogspot.com/_jcJUn2Pvhc0/TO0-lFQh6GI/AAAAAAAA_rA/Xo0zItu6zr4/s320/Screen%2Bshot%2B2010-11-24%2Bat%2B10.47.47%2BPM.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both;"&gt;4) Browse to your libraries path/directory. and select the file with the extension .iml&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_jcJUn2Pvhc0/TO0-llUfjHI/AAAAAAAA_rQ/1Al4mb76St8/s1600/Screen%2Bshot%2B2010-11-24%2Bat%2B10.47.23%2BPM.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="320" width="259" src="http://1.bp.blogspot.com/_jcJUn2Pvhc0/TO0-llUfjHI/AAAAAAAA_rQ/1Al4mb76St8/s320/Screen%2Bshot%2B2010-11-24%2Bat%2B10.47.23%2BPM.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div style="clear: both;"&gt;5) First click on your project (the red circle) then on the dependencies tab, click on add then Module dependencies (it shall have only one module)&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/_jcJUn2Pvhc0/TO1Ayoj3fcI/AAAAAAAA_rg/WVXcW3t5LB0/s1600/Screen%2Bshot%2B2010-11-24%2Bat%2B10.48.41%2BPM.png" imageanchor="1" style="clear:left; float:left;margin-right:1em; margin-bottom:1em"&gt;&lt;img border="0" height="230" width="320" src="http://1.bp.blogspot.com/_jcJUn2Pvhc0/TO1Ayoj3fcI/AAAAAAAA_rg/WVXcW3t5LB0/s320/Screen%2Bshot%2B2010-11-24%2Bat%2B10.48.41%2BPM.png" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="clear: both;"&gt;&lt;/div&gt;&lt;br /&gt;
&lt;a href="http://gan.doubleclick.net/gan_click?lid=41000000030280158&amp;pubid=21000000000270709"&gt;&lt;img src="http://gan.doubleclick.net/gan_impression?lid=41000000030280158&amp;pubid=21000000000270709" border=0 alt="Easy Updates 468x60"&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Command line&lt;/strong&gt;&lt;br /&gt;
So you can code with your favorite IDE and now you want to debug it on the emulator. you could do (please refer to &lt;a href="http://developer.android.com/guide/developing/other-ide.html#DebugMode"&gt;Developing in other IDE&lt;/a&gt; (You must have ant in your OS)&lt;br /&gt;
&lt;code&gt;cd /path/to/your/project&lt;br /&gt;
ant debug&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
It will then tell you that where the apk is at&lt;br /&gt;
&lt;code&gt;debug:&lt;br /&gt;
[echo] Running zip align on final apk...&lt;br /&gt;
[echo] Debug Package: /path/to/your/project/&lt;b&gt;bin/shootAndLearn-debug.apk&lt;/b&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Now you have to install it on the emulator, please refer to &lt;a href="http://developer.android.com/guide/developing/tools/adb.html"&gt;Android Debug Bridge page&lt;/a&gt;&lt;br /&gt;
&lt;code&gt;adb uninstall com.almondmendoza.shootAndLearn&lt;br /&gt;
adb install &lt;b&gt;bin/shootAndLearn-debug.apk&lt;/b&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color:#777"&gt;adb uninstall com.almondmendoza.shootAndLearn&lt;/i&gt;&lt;br /&gt;
We have to uninstall the apk from the emulator first before&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color:#777"&gt;adb install &lt;b&gt;bin/shootAndLearn-debug.apk&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
installing it&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Conclusion&lt;/strong&gt;&lt;br /&gt;
I know the debugging part is kinda hard right now but the development/coding part is certainly a lot better (got to love the ctrl+w, ctrl+shift+a shortcuts) :)</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/5897462506194409496/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=5897462506194409496" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5897462506194409496?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5897462506194409496?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/ACzs3F1Byi0/using-library-with-resources-in.html" title="Using library with resources in IntelliJ and Android" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/_jcJUn2Pvhc0/TO0-kRufzJI/AAAAAAAA_q4/C_L-YIPJt2Q/s72-c/Screen%2Bshot%2B2010-11-24%2Bat%2B10.48.21%2BPM.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/11/using-library-with-resources-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0AARXc9cCp7ImA9WhZbEEs.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-5716142120942850959</id><published>2010-11-21T02:02:00.002+08:00</published><updated>2011-06-14T22:29:04.968+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-14T22:29:04.968+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Drawing" /><category scheme="http://www.blogger.com/atom/ns#" term="Canvas" /><category scheme="http://www.blogger.com/atom/ns#" term="Bitmap" /><title>Drawing with Canvas in Android, Saving your drawings</title><content type="html">Continuing with our &lt;a href="http://www.tutorialforandroid.com/p/drawing-with-canvas-series.html"&gt;Drawing in Canvas series&lt;/a&gt;, let us see how to save your drawings&lt;br /&gt;
&lt;strong&gt;Update:&lt;/strong&gt;&lt;br /&gt;
May 5, 2011 - If saving the image is not that fine, this could come in handy &lt;a href="http://stackoverflow.com/questions/5243547/decode-byte-array-to-bitmap-that-has-been-compressed-in-java"&gt;http://stackoverflow.com/questions/5243547/decode-byte-array-to-bitmap-that-has-been-compressed-in-java&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Introduction&lt;/strong&gt;&lt;br /&gt;
We draw and saw our drawings are good, now lets save them&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Notes&lt;/strong&gt;&lt;br /&gt;
&amp;bull; The files are uploaded in &lt;a href="http://goo.gl/ecHpE"&gt;http://goo.gl/ecHpE&lt;/a&gt;&lt;br /&gt;
&amp;bull; The project was build in IntelliJ and it should be easy to import to Eclipse&lt;br /&gt;
&amp;bull; &lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;What Do I Need&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
DrawingSurface&lt;br /&gt;
&lt;pre name="code" class="java"&gt;public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback {
&amp;nbsp; private Bitmap mBitmap;
&amp;nbsp; private ...
&amp;nbsp; class DrawThread extends  Thread{
&amp;nbsp; &amp;nbsp; ...
&amp;nbsp; &amp;nbsp; @Override
&amp;nbsp; &amp;nbsp; public void run() {
&amp;nbsp; &amp;nbsp; &amp;nbsp; Canvas canvas = null;
&amp;nbsp; &amp;nbsp; &amp;nbsp; while (_run){
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; canvas = mSurfaceHolder.lockCanvas(null);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(mBitmap == null){
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mBitmap =  Bitmap.createBitmap (1, 1, Bitmap.Config.ARGB_8888);;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final Canvas c = new Canvas (mBitmap);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c.drawColor(0, PorterDuff.Mode.CLEAR);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; commandManager.executeAll(c);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; canvas.drawBitmap (mBitmap, 0,  0,null);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } finally {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mSurfaceHolder.unlockCanvasAndPost(canvas);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }

&amp;nbsp; public Bitmap getBitmap(){
&amp;nbsp; &amp;nbsp; return mBitmap;
&amp;nbsp; }

&amp;nbsp; public void surfaceChanged(SurfaceHolder holder, int format, int width,  int height) {
&amp;nbsp; &amp;nbsp; // TODO Auto-generated method stub
&amp;nbsp; &amp;nbsp; mBitmap =  Bitmap.createBitmap (width, height, Bitmap.Config.ARGB_8888);;
&amp;nbsp; }
}&lt;/pre&gt;&lt;br /&gt;
DrawingActivity&lt;br /&gt;
&lt;pre name="code" class="java"&gt;public class DrawingActivity extends Activity implements View.OnTouchListener{
&amp;nbsp; ...
&amp;nbsp; private static File APP_FILE_PATH = new File("/sdcard/TutorialForAndroidDrawings");

&amp;nbsp; public void onClick(View view){
&amp;nbsp; &amp;nbsp; switch (view.getId()){
&amp;nbsp; &amp;nbsp; &amp;nbsp; ...
&amp;nbsp; &amp;nbsp; &amp;nbsp; case R.id.saveBtn:
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final Activity currentActivity  = this;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Handler saveHandler = new Handler(){
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; @Override
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void handleMessage(Message msg) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final AlertDialog alertDialog = new AlertDialog.Builder(currentActivity).create();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alertDialog.setTitle("Saved 1");
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alertDialog.setMessage("Your drawing had been saved :)");
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public void onClick(DialogInterface dialog, int which) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; alertDialog.show();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } ;
&amp;nbsp; &amp;nbsp; &amp;nbsp;    new ExportBitmapToFile(this,saveHandler, drawingSurface.getBitmap()).execute();
&amp;nbsp; &amp;nbsp; &amp;nbsp; break;
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }


&amp;nbsp; private class ExportBitmapToFile extends AsyncTask&lt;Intent,Void,Boolean&gt; {
&amp;nbsp; &amp;nbsp; private Context mContext;
&amp;nbsp; &amp;nbsp; private Handler mHandler;
&amp;nbsp; &amp;nbsp; private Bitmap nBitmap;

&amp;nbsp; &amp;nbsp; public ExportBitmapToFile(Context context,Handler handler,Bitmap bitmap) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; mContext = context;
&amp;nbsp; &amp;nbsp; &amp;nbsp; nBitmap = bitmap;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mHandler = handler;
&amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; @Override
&amp;nbsp; &amp;nbsp; protected Boolean doInBackground(Intent... arg0) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; try {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!APP_FILE_PATH.exists()) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; APP_FILE_PATH.mkdirs();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final FileOutputStream out = new FileOutputStream(new File(APP_FILE_PATH + "/myAwesomeDrawing.png"));
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; nBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.flush();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; out.close();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return true;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }catch (Exception e) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.printStackTrace();
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; //mHandler.post(completeRunnable);
&amp;nbsp; &amp;nbsp; &amp;nbsp; return false;
&amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; @Override
&amp;nbsp; &amp;nbsp; protected void onPostExecute(Boolean bool) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; super.onPostExecute(bool);
&amp;nbsp; &amp;nbsp; &amp;nbsp; if ( bool ){
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mHandler.sendEmptyMessage(1);
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Quick Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;div class="amazonAssociates" style="float: right; width:130px"&gt;Ads from Amazon: &lt;iframe src="http://rcm.amazon.com/e/cm?t=monmonja05-20&amp;o=1&amp;p=8&amp;l=bpl&amp;asins=1449383262&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="align:left;padding-top:5px;width:131px;height:245px;padding-right:10px;"align="left" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;strong style="font-size: 110%;"&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;i style="color: #777777;"&gt;if(mBitmap == null){&lt;br /&gt;
&amp;nbsp; mBitmap =  Bitmap.createBitmap (1, 1, Bitmap.Config.ARGB_8888);;&lt;br /&gt;
}&lt;br /&gt;
final Canvas c = new Canvas (mBitmap);&lt;br /&gt;
c.drawColor(0, PorterDuff.Mode.CLEAR);&lt;br /&gt;
commandManager.executeAll(c);&lt;/i&gt;&lt;br /&gt;
This is the core of the saving part, in order for our drawing to be exported we have to create a canvas with bitmap to draw upon to, See &lt;a href="http://developer.android.com/reference/android/graphics/Canvas.html#Canvas(android.graphics.Bitmap)"&gt;Canvas Class&lt;/a&gt; for more info.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777"&gt;canvas.drawBitmap (mBitmap, 0,  0,null);&lt;/i&gt;&lt;br /&gt;
We put our bitmap to our original canvas (the surfaceView's canvas) so that we can see our drawings&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777"&gt;public void surfaceChanged(SurfaceHolder holder, int format, int width,  int height) {&lt;br /&gt;
&amp;nbsp; mBitmap =  Bitmap.createBitmap (width, height, Bitmap.Config.ARGB_8888);;&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
We would have to recreate our bitmap when we change the orientation (The drawings will currently be removed)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777"&gt;final Activity currentActivity  = this;&lt;br /&gt;
Handler saveHandler = new Handler(){ ... }&lt;/i&gt;&lt;br /&gt;
We cant call the UI tread from another thread so we pass a handler to our AsyncTask, see &lt;a href="http://www.tutorialforandroid.com/2009/01/using-handler-in-android.html"&gt;Using Handler in Android&lt;/a&gt; for more information on Handlers&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777"&gt;private class ExportBitmapToFile extends AsyncTask&lt;Intent,Void,Boolean&gt; {&lt;br /&gt;
&amp;nbsp; private Context mContext;&lt;br /&gt;
&amp;nbsp; private Handler mHandler;&lt;br /&gt;
&amp;nbsp; private Bitmap nBitmap;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; public ExportBitmapToFile(Context context,Handler handler,Bitmap bitmap) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; mContext = context;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; nBitmap = bitmap;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; mHandler = handler;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; protected Boolean doInBackground(Intent... arg0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; try {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; if (!APP_FILE_PATH.exists()) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; APP_FILE_PATH.mkdirs();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; final FileOutputStream out = new FileOutputStream(new File(APP_FILE_PATH + "/myAwesomeDrawing.png"));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; nBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; out.flush();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; out.close();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; return true;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }catch (Exception e) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; e.printStackTrace();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //mHandler.post(completeRunnable);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return false;&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; @Override&lt;br /&gt;
&amp;nbsp; protected void onPostExecute(Boolean bool) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; super.onPostExecute(bool);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; if ( bool ){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mHandler.sendEmptyMessage(1);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
In order for us to export the bitmap and not hard the UX of our app, we need to create a background thread for it, for more information on AsyncTask see the &lt;a href="http://developer.android.com/reference/android/os/AsyncTask.html"&gt;AsyncTask Class&lt;/a&gt; and &lt;a href="http://android-developers.blogspot.com/2009/05/painless-threading.html"&gt;Painless Threading&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color:#777777"&gt;final FileOutputStream out = new FileOutputStream(new File(APP_FILE_PATH + "/myAwesomeDrawing.png"));&lt;br /&gt;
nBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);&lt;br /&gt;
out.flush();&lt;br /&gt;
out.close();&lt;/i&gt;&lt;br /&gt;
This is default Java feature, if your now from Java then this just mean that you create a buffer where when we use that in mBitmap.compress the compressed bitmap would be buffered into that FileOutputStream (i hope i was clear in this. haha)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Reference&lt;/strong&gt;&lt;br /&gt;
Most of the stuff here were back in 2009, most of them are in Google Groups.</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/5716142120942850959/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=5716142120942850959" title="8 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5716142120942850959?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/5716142120942850959?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/y65l0m91F-c/drawing-with-canvas-in-android-saving.html" title="Drawing with Canvas in Android, Saving your drawings" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>8</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/11/drawing-with-canvas-in-android-saving.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEBQnY4cCp7ImA9WhRVF0s.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-6149590413646710802</id><published>2010-11-17T00:49:00.002+08:00</published><updated>2012-01-17T09:10:53.838+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-17T09:10:53.838+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Design Patterns" /><category scheme="http://www.blogger.com/atom/ns#" term="Drawing" /><category scheme="http://www.blogger.com/atom/ns#" term="Canvas" /><title>Drawing with Canvas in Android, Undo/Redo with Command Pattern</title><content type="html">&lt;strong&gt;Update - Nov 21, 2010&lt;/strong&gt;&lt;br /&gt;
Created a series over this topic over at &lt;a href="http://www.tutorialforandroid.com/p/drawing-with-canvas-series.html"&gt;Drawing with Canvas Series&lt;/a&gt;, more articles would appear in the future :) &lt;br /&gt;
&lt;br /&gt;
Continuing our Drawing with Canvas in Android, lets implement Undo and Redo with &lt;a href="http://en.wikipedia.org/wiki/Command_pattern"&gt;Command Pattern &lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Introduction&lt;/strong&gt;&lt;br /&gt;
We draw and make mistake, and when we do we may want to undo it and when we undo we might want to redo it. Lets use a common design pattern in dealing with undo (I believe this is a modified command pattern for the command manager but i might be wrong)&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Notes&lt;/strong&gt;&lt;br /&gt;
&amp;bull; This is a continuation of &lt;a href="http://www.tutorialforandroid.com/2010/11/drawing-with-canvas-in-android-renewed.html"&gt;Drawing with Canvas in Android Renewed&lt;/a&gt;&lt;br /&gt;
&amp;bull; The files are uploaded in &lt;a href="http://goo.gl/ecHpE"&gt;http://goo.gl/ecHpE&lt;/a&gt;&lt;br /&gt;
&amp;bull; The project was build in IntelliJ and it should be easy to import to Eclipse&lt;br /&gt;
&amp;bull; &lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;What Do I Need&lt;/strong&gt;&lt;br /&gt;
ICanvasCommand&lt;br /&gt;
&lt;pre name="code" class="java"&gt;public interface ICanvasCommand {
&amp;nbsp; public void draw(Canvas canvas);
&amp;nbsp; public void undo();
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
DrawingPath&lt;br /&gt;
&lt;pre name="code" class="java"&gt;public class DrawingPath implements ICanvasCommand{
&amp;nbsp; public Path path;
&amp;nbsp; public Paint paint;

&amp;nbsp; public void draw(Canvas canvas) {
&amp;nbsp; &amp;nbsp; canvas.drawPath( path, paint );
&amp;nbsp; }

&amp;nbsp; public void undo() {
&amp;nbsp; &amp;nbsp; //Todo this would be changed later
&amp;nbsp; }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
CommandManager&lt;br /&gt;
&lt;pre name="code" class="java"&gt;public class CommandManager {
&amp;nbsp; private List&lt;drawingpath&gt; currentStack;
&amp;nbsp; private List&lt;drawingpath&gt; redoStack;

&amp;nbsp; public  CommandManager(){
&amp;nbsp; &amp;nbsp; currentStack = Collections.synchronizedList(new ArrayList&lt;drawingpath&gt;());
&amp;nbsp; &amp;nbsp; redoStack = Collections.synchronizedList(new ArrayList&lt;drawingpath&gt;());
&amp;nbsp; }

&amp;nbsp; public void addCommand(DrawingPath command){
&amp;nbsp; &amp;nbsp; redoStack.clear();
&amp;nbsp; &amp;nbsp; currentStack.add(command);
&amp;nbsp; }

&amp;nbsp; public void undo (){
&amp;nbsp; &amp;nbsp; final int length = currentStackLength();
&amp;nbsp; &amp;nbsp; if ( length &gt; 0) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; final DrawingPath undoCommand = currentStack.get(  length - 1  );
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentStack.remove( length - 1 );
&amp;nbsp; &amp;nbsp; &amp;nbsp; undoCommand.undo();
&amp;nbsp; &amp;nbsp; &amp;nbsp; redoStack.add( undoCommand );
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }

&amp;nbsp; public int currentStackLength(){
&amp;nbsp; &amp;nbsp; final int length = currentStack.toArray().length;
&amp;nbsp; &amp;nbsp; return length;
&amp;nbsp; }

&amp;nbsp; public void executeAll( Canvas canvas){
&amp;nbsp; &amp;nbsp; if( currentStack != null ){
&amp;nbsp; &amp;nbsp; &amp;nbsp; synchronized( currentStack ) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final Iterator i = currentStack.iterator();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while ( i.hasNext() ){
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final DrawingPath drawingPath = (DrawingPath) i.next();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; drawingPath.draw( canvas );
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }

&amp;nbsp; public boolean hasMoreRedo(){
&amp;nbsp; &amp;nbsp; return  redoStack.toArray().length &gt; 0;
&amp;nbsp; }

&amp;nbsp; public boolean hasMoreUndo(){
&amp;nbsp; &amp;nbsp; return  currentStack.toArray().length &gt; 0;
&amp;nbsp; }

&amp;nbsp; public void redo(){
&amp;nbsp; &amp;nbsp; final int length = redoStack.toArray().length;
&amp;nbsp; &amp;nbsp; if ( length &gt; 0) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; final DrawingPath redoCommand = redoStack.get(  length - 1  );
&amp;nbsp; &amp;nbsp; &amp;nbsp; redoStack.remove( length - 1 );
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentStack.add( redoCommand );
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
DrawingSurface&lt;br /&gt;
&lt;pre name="code" class="java"&gt;public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback {
&amp;nbsp; private CommandManager commandManager;

&amp;nbsp; public DrawingSurface(Context context, AttributeSet attrs) {
&amp;nbsp; &amp;nbsp; ...
&amp;nbsp; &amp;nbsp; commandManager = new CommandManager();
&amp;nbsp; &amp;nbsp; ...
&amp;nbsp; }

&amp;nbsp; class DrawThread extends  Thread{
&amp;nbsp; &amp;nbsp; ...
&amp;nbsp; &amp;nbsp; @Override
&amp;nbsp; &amp;nbsp; public void run() {
&amp;nbsp; &amp;nbsp; &amp;nbsp; Canvas canvas = null;
&amp;nbsp; &amp;nbsp; &amp;nbsp; while (_run){
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; canvas = mSurfaceHolder.lockCanvas(null);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; canvas.drawColor(0, PorterDuff.Mode.CLEAR);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; commandManager.executeAll(canvas);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ....
&amp;nbsp; }

&amp;nbsp; public void addDrawingPath (DrawingPath drawingPath){
&amp;nbsp; &amp;nbsp; commandManager.addCommand(drawingPath);
&amp;nbsp; }

&amp;nbsp; public boolean hasMoreRedo(){
&amp;nbsp; &amp;nbsp; return commandManager.hasMoreRedo();
&amp;nbsp; }

&amp;nbsp; public void redo(){
&amp;nbsp; &amp;nbsp; commandManager.redo();
&amp;nbsp; }

&amp;nbsp; public void undo(){
&amp;nbsp; &amp;nbsp; commandManager.undo();
&amp;nbsp; }

&amp;nbsp; public boolean hasMoreUndo(){
&amp;nbsp; &amp;nbsp; return commandManager.hasMoreUndo();
&amp;nbsp; }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
DrawingActivity&lt;br /&gt;
See the source should be simple enough to be understood :)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="amazonAssociates" style="float: right; width:130px"&gt;Ads from Amazon: &lt;iframe src="http://rcm.amazon.com/e/cm?t=monmonja05-20&amp;o=1&amp;p=8&amp;l=bpl&amp;asins=0321673352&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="align:left;padding-top:5px;width:131px;height:245px;padding-right:10px;"align="left" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;strong style="font-size: 110%;"&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public interface ICanvasCommand {&lt;br /&gt;
&amp;nbsp; public void draw(Canvas canvas);&lt;br /&gt;
&amp;nbsp; public void undo();&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
In undo command pattern based we need need 2 methods, one is execute and the other is undo (we wont use undo currently) &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public class DrawingPath implements ICanvasCommand{&lt;br /&gt;
&amp;nbsp; public Path path;&lt;br /&gt;
&amp;nbsp; public Paint paint;&lt;br /&gt;
&amp;nbsp; public void draw(Canvas canvas) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; canvas.drawPath( path, paint );&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; public void undo() {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; //Todo this would be changed later&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
Let us now implement our interface, the code should be easy to understand. canvas.drawPath( path, paint) would draw our path with the object's paint into our class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;currentStack = Collections.synchronizedList(new ArrayList&lt;drawingpath&gt;());&lt;br /&gt;
redoStack = Collections.synchronizedList(new ArrayList&lt;drawingpath&gt;());&lt;/i&gt;&lt;br /&gt;
We create 2 List (Its actually a Stack but seems Stack cannot be thread-safe and I dont freakin understand why there are a lot of Array variation in Java, its so messy), one called currentStack for the current paths, another is redoStack where we put the undo commands so we could do redos.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public void addCommand(DrawingPath command){&lt;br /&gt;
&amp;nbsp; redoStack.clear();&lt;br /&gt;
&amp;nbsp; currentStack.add(command);&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
Everytime we add a new command, we should clear the redoStack&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class="amazonAssociates" style="float: right; width:130px"&gt;Ads from Amazon: &lt;iframe src="http://rcm.amazon.com/e/cm?t=monmonja05-20&amp;o=1&amp;p=8&amp;l=bpl&amp;asins=047077018X&amp;fc1=000000&amp;IS2=1&amp;lt1=_blank&amp;m=amazon&amp;lc1=0000FF&amp;bc1=000000&amp;bg1=FFFFFF&amp;f=ifr" style="align:left;padding-top:5px;width:131px;height:245px;padding-right:10px;"align="left" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;i style="color: #777777;"&gt;public void undo (){&lt;br /&gt;
&amp;nbsp; final int length = currentStackLength();&lt;br /&gt;
&amp;nbsp; if ( length &gt; 0) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; final DrawingPath undoCommand = currentStack.get(  length - 1  );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentStack.remove( length - 1 );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; undoCommand.undo();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; redoStack.add( undoCommand );&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
When we do an undo, we pop the last command from the currentStack and push it to our redoStack. As you can see we implemented undoCommand.undo() we did this incase in the future we have some logics added to our undo function&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public void executeAll( Canvas canvas){&lt;br /&gt;
&amp;nbsp; if( currentStack != null ){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; synchronized( currentStack ) {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; final Iterator i = currentStack.iterator();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; while ( i.hasNext() ){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final DrawingPath drawingPath = (DrawingPath) i.next();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; drawingPath.draw( canvas );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
We loop through our currentStack and do the execute part (.draw) from our command pattern.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;canvas = mSurfaceHolder.lockCanvas(null);&lt;br /&gt;
canvas.drawColor(0, PorterDuff.Mode.CLEAR);&lt;br /&gt;
commandManager.executeAll(canvas);&lt;/i&gt;&lt;br /&gt;
In order for our undo/redo to work we have to somehow clear the canvas and &lt;i&gt;drawColor(0, PorterDuff.Mode.CLEAR)&lt;/i&gt; helps us with that&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Some of the codes are, i believe, logical thus i skip the explanation on them.</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/6149590413646710802/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=6149590413646710802" title="6 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/6149590413646710802?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/6149590413646710802?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/aHFTc4Drg1I/drawing-with-canvas-in-android-undoredo.html" title="Drawing with Canvas in Android, Undo/Redo with Command Pattern" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>6</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/11/drawing-with-canvas-in-android-undoredo.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkcARXg5eyp7ImA9WhdbEk8.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-9205554879380280333</id><published>2010-11-13T02:56:00.002+08:00</published><updated>2011-10-10T14:27:24.623+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-10-10T14:27:24.623+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Drawing" /><category scheme="http://www.blogger.com/atom/ns#" term="Canvas" /><title>Drawing with Canvas in Android Renewed</title><content type="html">&lt;strong&gt;Update - Nov 21, 2010&lt;/strong&gt;&lt;br /&gt;
Created a series over this topic over at &lt;a href="http://www.tutorialforandroid.com/p/drawing-with-canvas-series.html"&gt;Drawing with Canvas Series&lt;/a&gt;, more articles would appear in the future :) &lt;br /&gt;
&lt;br /&gt;
Back one year ago, i blogged about &lt;a href="http://www.tutorialforandroid.com/2009/06/drawing-with-canvas-in-android.html"&gt;Drawing with Canvas in Android&lt;/a&gt;, at that time i was creating a drawing app that never get released (lazy me). Now im planning to redo everything and share my learnings as i go on (I'm still doing the Shoot and Learn on the side). From the simple tutorial on how to draw canvas in android, lets explode this area further.&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Introduction&lt;/strong&gt;&lt;br /&gt;
Based on the &lt;a href="http://www.tutorialforandroid.com/2009/06/drawing-with-canvas-in-android.html"&gt;Drawing with Canvas in Android&lt;/a&gt; lets put the SurfaceView into a separate class (you should know how to &lt;a href="http://developer.android.com/guide/topics/ui/custom-components.html"&gt;use custom view&lt;/a&gt;), create a DrawingPath class which would contain our Path and Paint object, and create a DrawingActivity where our touch events, buttons to change colors are located.&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Notes&lt;/strong&gt;&lt;br /&gt;
&amp;bull; The package i would use through this tutorial is &lt;strong&gt;com.almondmendoza.drawings&lt;/strong&gt;&lt;br /&gt;
&amp;bull; The individual source are located at &lt;a href="https://docs.google.com/leaf?id=0B-O-OZiPmCOqYTRlMGFiZjctODYxYS00ZjU1LThjZGYtMWQyMzRiNmIwY2Rm&amp;sort=name&amp;layout=list&amp;num=50"&gt;http://goo.gl/5GulF&lt;/a&gt; while the full ones is at &lt;a href="https://sites.google.com/site/tutorialsformobileprogramming/android-tutorials/android-files"&gt;https://sites.google.com/site/tutorialsformobileprogramming/android-tutorials/android-files&lt;/a&gt;&lt;br /&gt;
&amp;bull; In this tutorial we wont handle clearing up the images, &lt;a href="http://www.tutorialforandroid.com/2010/11/drawing-with-canvas-in-android-undoredo.html"&gt;undos/redos&lt;/a&gt; and screen rotations (all in future articles :) )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;What Do I Need&lt;/strong&gt;&lt;br /&gt;
Drawing Activity&lt;br /&gt;
&lt;pre class="xml" name="code"&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&gt;
&amp;lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
&amp;nbsp; &amp;nbsp; ....
&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;com.almondmendoza.drawings.DrawingSurface
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android:layout_width="match_parent"
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android:layout_height="match_parent"
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; android:id="@+id/drawingSurface"
&amp;nbsp; &amp;nbsp; /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;LinearLayout
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .....
&amp;nbsp; &amp;nbsp; &gt;
&amp;nbsp; &amp;nbsp; ......
&amp;nbsp; &amp;nbsp; &amp;lt;/LinearLayout&gt;
&amp;lt;/RelativeLayout&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Main Activity&lt;br /&gt;
&lt;pre class="java" name="code"&gt;Intent drawIntent = new Intent(this, DrawingActivity.class);
startActivity( drawIntent);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
DrawingPath.java&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public class DrawingPath {
&amp;nbsp; public Path path;
&amp;nbsp; public Paint paint;
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Drawing Activity&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public class DrawingActivity extends Activity implements View.OnTouchListener{
&amp;nbsp; private DrawingSurface drawingSurface;
&amp;nbsp; private DrawingPath currentDrawingPath;
&amp;nbsp; private Paint currentPaint;

&amp;nbsp; public void onCreate(Bundle savedInstanceState) {
&amp;nbsp; &amp;nbsp; super.onCreate(savedInstanceState);
&amp;nbsp; &amp;nbsp; setContentView(R.layout.drawing_activity);
&amp;nbsp; &amp;nbsp; setCurrentPaint();
&amp;nbsp; &amp;nbsp; drawingSurface = (DrawingSurface) findViewById(R.id.drawingSurface);
&amp;nbsp; &amp;nbsp; drawingSurface.setOnTouchListener(this);
&amp;nbsp; }

&amp;nbsp; private void setCurrentPaint(){
&amp;nbsp; &amp;nbsp; currentPaint = new Paint();
&amp;nbsp; &amp;nbsp; currentPaint.setDither(true);
&amp;nbsp; &amp;nbsp; currentPaint.setColor(0xFFFFFF00);
&amp;nbsp; &amp;nbsp; currentPaint.setStyle(Paint.Style.STROKE);
&amp;nbsp; &amp;nbsp; currentPaint.setStrokeJoin(Paint.Join.ROUND);
&amp;nbsp; &amp;nbsp; currentPaint.setStrokeCap(Paint.Cap.ROUND);
&amp;nbsp; &amp;nbsp; currentPaint.setStrokeWidth(3);
&amp;nbsp; }

&amp;nbsp; public boolean onTouch(View view, MotionEvent motionEvent) {
&amp;nbsp; &amp;nbsp; if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentDrawingPath = new DrawingPath();
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentDrawingPath.paint = currentPaint;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentDrawingPath.path = new Path();
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentDrawingPath.path.moveTo(motionEvent.getX(), motionEvent.getY());
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentDrawingPath.path.lineTo(motionEvent.getX(), motionEvent.getY());
&amp;nbsp; &amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentDrawingPath.path.lineTo(motionEvent.getX(), motionEvent.getY());
&amp;nbsp; &amp;nbsp; }else if(motionEvent.getAction() == MotionEvent.ACTION_UP){
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentDrawingPath.path.lineTo(motionEvent.getX(), motionEvent.getY());
&amp;nbsp; &amp;nbsp; &amp;nbsp; drawingSurface.addDrawingPath(currentDrawingPath);
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; return true;
&amp;nbsp; }

&amp;nbsp; public void onClick(View view){
&amp;nbsp; &amp;nbsp; switch (view.getId()){
&amp;nbsp; &amp;nbsp; &amp;nbsp; case R.id.colorRedBtn:
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint = new Paint();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setDither(true);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setColor(0xFFFF0000);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStyle(Paint.Style.STROKE);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeJoin(Paint.Join.ROUND);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeCap(Paint.Cap.ROUND);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeWidth(3);
&amp;nbsp; &amp;nbsp; &amp;nbsp; break;
&amp;nbsp; &amp;nbsp; &amp;nbsp; case R.id.colorBlueBtn:
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint = new Paint();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setDither(true);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setColor(0xFF00FF00);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStyle(Paint.Style.STROKE);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeJoin(Paint.Join.ROUND);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeCap(Paint.Cap.ROUND);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeWidth(3);
&amp;nbsp; &amp;nbsp; &amp;nbsp; break;
&amp;nbsp; &amp;nbsp; &amp;nbsp; case R.id.colorGreenBtn:
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint = new Paint();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setDither(true);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setColor(0xFF0000FF);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStyle(Paint.Style.STROKE);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeJoin(Paint.Join.ROUND);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeCap(Paint.Cap.ROUND);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setStrokeWidth(3);
&amp;nbsp; &amp;nbsp; &amp;nbsp; break;
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Drawing Surface&lt;br /&gt;
&lt;pre class="java" name="code"&gt;public class DrawingSurface extends SurfaceView implements SurfaceHolder.Callback {
&amp;nbsp; private Boolean _run;
&amp;nbsp; protected DrawThread thread;

&amp;nbsp; public DrawingSurface(Context context, AttributeSet attrs) {
...
&amp;nbsp; }

&amp;nbsp; public void addDrawingPath (DrawingPath drawingPath){
&amp;nbsp; &amp;nbsp; thread.addDrawingPath(drawingPath);
&amp;nbsp; }

&amp;nbsp; class DrawThread extends  Thread{
&amp;nbsp; &amp;nbsp; private SurfaceHolder mSurfaceHolder;
&amp;nbsp; &amp;nbsp; private List&lt;drawingpath&gt; mDrawingPaths;
&amp;nbsp; &amp;nbsp; public DrawThread(SurfaceHolder surfaceHolder){
&amp;nbsp; &amp;nbsp; &amp;nbsp; mSurfaceHolder = surfaceHolder;
&amp;nbsp; &amp;nbsp; &amp;nbsp; mDrawingPaths = Collections.synchronizedList(new ArrayList&lt;drawingpath&gt;());
&amp;nbsp; &amp;nbsp; }

...

&amp;nbsp; &amp;nbsp; public void addDrawingPath(DrawingPath drawingPath){
&amp;nbsp; &amp;nbsp; &amp;nbsp; mDrawingPaths.add( drawingPath );
&amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; @Override
&amp;nbsp; &amp;nbsp; public void run() {
&amp;nbsp; &amp;nbsp; &amp;nbsp; Canvas canvas = null;
&amp;nbsp; &amp;nbsp; &amp;nbsp; while (_run){
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try{
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; canvas = mSurfaceHolder.lockCanvas(null);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; synchronized(mDrawingPaths) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Iterator i = mDrawingPaths.iterator();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; while (i.hasNext()){
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final DrawingPath drawingPath = (DrawingPath) i.next();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; canvas.drawPath(drawingPath.path, drawingPath.paint);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } finally {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mSurfaceHolder.unlockCanvasAndPost(canvas);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }
....
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;i style="color: #777777;"&gt;&amp;lt;com.almondmendoza.drawings.DrawingSurface&lt;br /&gt;
&amp;nbsp; android:layout_width="match_parent"&lt;br /&gt;
&amp;nbsp; android:layout_height="match_parent"&lt;br /&gt;
&amp;nbsp; android:id="@+id/drawingSurface"&lt;br /&gt;
/&gt;&lt;/i&gt;&lt;br /&gt;
We start off by using our custom view in our xml, its as simple as creating a class and using it on the layout.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public class DrawingPath {&lt;br /&gt;
&amp;nbsp; public Path path;&lt;br /&gt;
&amp;nbsp; public Paint paint;&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
From &lt;a href="http://www.tutorialforandroid.com/2009/06/drawing-with-canvas-in-android.html"&gt;Drawing with Canvas in Android&lt;/a&gt; we learn to put an ArrayList of Path which have a single color, for us to have different colors on different path, we create a class which would be an List in our DrawThread later on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;private Paint currentPaint;&lt;br /&gt;
....&lt;br /&gt;
private void setCurrentPaint(){&lt;br /&gt;
&amp;nbsp; currentPaint = new Paint();&lt;br /&gt;
&amp;nbsp; currentPaint.setDither(true);&lt;br /&gt;
&amp;nbsp; currentPaint.setColor(0xFFFFFF00);&lt;br /&gt;
&amp;nbsp; currentPaint.setStyle(Paint.Style.STROKE);&lt;br /&gt;
&amp;nbsp; currentPaint.setStrokeJoin(Paint.Join.ROUND);&lt;br /&gt;
&amp;nbsp; currentPaint.setStrokeCap(Paint.Cap.ROUND);&lt;br /&gt;
&amp;nbsp; currentPaint.setStrokeWidth(3);&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
Here we create a Paint that would serve as our current paint, and set the currentPaint at the start of our activity.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;&amp;nbsp; public void onClick(View view){&lt;br /&gt;
&amp;nbsp; switch (view.getId()){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; case R.id.colorRedBtn:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint = new Paint();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setDither(true);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setColor(0xFFFF0000);&lt;br /&gt;
...&lt;br /&gt;
&amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; case R.id.colorBlueBtn:&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint = new Paint();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setDither(true);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; currentPaint.setColor(0xFF00FF00);&lt;br /&gt;
...&lt;/i&gt;&lt;br /&gt;
This is how we change the currentPaint's color, since we use the Paint object, you could use any of its property/methods thus making every Path beautiful :)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;&amp;nbsp; public boolean onTouch(View view, MotionEvent motionEvent) {&lt;br /&gt;
&amp;nbsp; if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentDrawingPath = new DrawingPath();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentDrawingPath.paint = currentPaint;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; currentDrawingPath.path = new Path();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; ....&lt;br /&gt;
&amp;nbsp; &amp;nbsp; drawingSurface.addDrawingPath(currentDrawingPath);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
&amp;nbsp; return true;&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
In the previous tutorial, we bind our onTouch on the surfaceView directly, now we bind it in our activity, this way we could control the logic of the touches better (where you would apply your own shared touch library) and you could do things that doesnt harm the SurfaceView/Canvas.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public DrawThread(SurfaceHolder surfaceHolder){&lt;br /&gt;
&amp;nbsp; mSurfaceHolder = surfaceHolder;&lt;br /&gt;
&amp;nbsp; mDrawingPaths = Collections.synchronizedList(new ArrayList&lt;drawingpath&gt;());&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
As stated earlier we would create a List of DrawingPath, but in able to manipulate it while our thread is running we need to make sure that its thread-safe thus we call Collections.synchronizedList(new ArrayList&lt;drawingpath&gt;()); (I'm not sure about this since i never used threads in other language besides Javascript's webworker)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;&amp;nbsp; public void addDrawingPath (DrawingPath drawingPath){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; thread.addDrawingPath(drawingPath);&lt;br /&gt;
&amp;nbsp; }&lt;/i&gt;&lt;br /&gt;
From our activity we would pass a DrawingPath to our surfaceView which we would then pass it to our thread, we do this so that our thread would not be accessible to the outside world of our DrawingSurface, which i believe is better for we can inject logics that would deal with our SurfaceView before passing it to our thread.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;public void addDrawingPath(DrawingPath drawingPath){&lt;br /&gt;
&amp;nbsp; mDrawingPaths.add( drawingPath );&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
From our DrawingSurface to our DrawThread, we pass the a DrawingPath and add it to our list&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;synchronized(mDrawingPaths) {&lt;br /&gt;
&amp;nbsp; Iterator i = mDrawingPaths.iterator();&lt;br /&gt;
&amp;nbsp; while (i.hasNext()){&lt;br /&gt;
&amp;nbsp; &amp;nbsp; final DrawingPath drawingPath = (DrawingPath) i.next();&lt;br /&gt;
&amp;nbsp; &amp;nbsp; canvas.drawPath(drawingPath.path, drawingPath.paint);&lt;br /&gt;
&amp;nbsp; }&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
Here we use the Iterator class to iterate over our DrawingPath list and draw our Path on the canvas.&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size:110%"&gt;Conclusion&lt;/strong&gt;&lt;br /&gt;
Now we learn how to better put our codes and make sure it can be scale up (im a webdeveloper, ahha) in the future.&lt;br /&gt;
&lt;br /&gt;
Hope this helps :)</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/9205554879380280333/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=9205554879380280333" title="12 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/9205554879380280333?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/9205554879380280333?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/EanVJMM6iqE/drawing-with-canvas-in-android-renewed.html" title="Drawing with Canvas in Android Renewed" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>12</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/11/drawing-with-canvas-in-android-renewed.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkYMQnkyfyp7ImA9WhRVF0g.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-6323346023498926968</id><published>2010-10-30T23:26:00.001+08:00</published><updated>2012-01-17T07:56:23.797+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-17T07:56:23.797+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Picture" /><category scheme="http://www.blogger.com/atom/ns#" term="MediaStore" /><category scheme="http://www.blogger.com/atom/ns#" term="Gallery" /><title>Take Picture in Android with MediaStore.ACTION_IMAGE_CAPTURE</title><content type="html">Previously in Android when you want to capture an Image, you have to use SurfaceView and SurfaceHolder to preview the camera. &lt;a href="http://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE"&gt;MediaStore.ACTION_IMAGE_CAPTURE&lt;/a&gt; was introduced in Cupcake, Android 1.5, and has been the default way to capture images captured in Android. &lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;What Do I Need&lt;/strong&gt;&lt;br /&gt;
&lt;i&gt;In Manafiest.xml&lt;/i&gt;&lt;br /&gt;
&amp;lt;uses-permission android:name="android.permission.CAMERA" /&amp;gt;&lt;br /&gt;
&amp;lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;In your activity&lt;/i&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;private static final int TAKE_PHOTO_CODE = 1;

private void takePhoto(){
&amp;nbsp; final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
&amp;nbsp; intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(this)) ); 
&amp;nbsp; startActivityForResult(intent, TAKE_PHOTO_CODE);
}

private File getTempFile(Context context){
&amp;nbsp; //it will return /sdcard/image.tmp
&amp;nbsp; final File path = new File( Environment.getExternalStorageDirectory(), context.getPackageName() );
&amp;nbsp; if(!path.exists()){
&amp;nbsp; &amp;nbsp; path.mkdir();
&amp;nbsp; }
&amp;nbsp; return new File(path, "image.tmp");
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
&amp;nbsp; if (resultCode == RESULT_OK) {
&amp;nbsp; &amp;nbsp; switch(requestCode){
&amp;nbsp; &amp;nbsp; &amp;nbsp; case TAKE_PHOTO_CODE:
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; final File file = getTempFile(this);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Bitmap captureBmp = Media.getBitmap(getContentResolver(), Uri.fromFile(file) );
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // do whatever you want with the bitmap (Resize, Rename, Add To Gallery, etc)
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (FileNotFoundException e) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.printStackTrace();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (IOException e) {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.printStackTrace();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }
&amp;nbsp; &amp;nbsp; &amp;nbsp; break;
&amp;nbsp; &amp;nbsp; }
&amp;nbsp; }
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class="amazonAssociates" style="float: right;"&gt;Ads from Amazon: &lt;br /&gt;
&lt;iframe align="left" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" src="http://rcm.amazon.com/e/cm?t=monmonja05-20&amp;amp;o=1&amp;amp;p=8&amp;amp;l=bpl&amp;amp;asins=1934356565&amp;amp;fc1=000000&amp;amp;IS2=1&amp;amp;lt1=_blank&amp;amp;m=amazon&amp;amp;lc1=0000FF&amp;amp;bc1=000000&amp;amp;bg1=FFFFFF&amp;amp;f=ifr" style="align: left; height: 245px; padding-right: 10px; padding-top: 5px; width: 131px;"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;strong style="font-size: 110%;"&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;i style="color: #777777;"&gt;final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);&lt;br /&gt;
intent.putExtra(MediaStore.EXTRA_OUTPUT, getTempFile(this) );&lt;br /&gt;
startActivityForResult(intent, TAKE_PHOTO_CODE);&lt;/i&gt;&lt;br /&gt;
This is the core of the code, here we call an intent from the MediaStore which would open up the camera app, then we pass the output path of the captured image to a temporary location (Always use a safe location to store the image). Here we use the Environment.getExternalStorageDirectory() which is our SDCard, again for safety reason check if the SDCard is present or not. Then we start the activity, expecting a result with code TAKE_PHOTO_CODE&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color: #777777;"&gt;final File file = getTempFile(this);&lt;br /&gt;
try {&lt;br /&gt;
Bitmap captureBmp = Media.getBitmap(getContentResolver(), Uri.fromFile(file) );&lt;br /&gt;
}...{}&lt;/i&gt;&lt;br /&gt;
Knowing where the output of the file will be, we would open that file and place it on a bitmap where we would do our magic&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size: 110%;"&gt;Conclusion&lt;/strong&gt;&lt;br /&gt;
ACTION_IMAGE_CAPTURE has done a great job so that we wont implement our own implementation of the camera app, so use it.


&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;Update History&lt;/strong&gt;
&lt;br /&gt;&amp;nbsp; &amp;nbsp;&lt;em&gt;Jan 17, 2012 - Visual Update&lt;/em&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/6323346023498926968/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=6323346023498926968" title="12 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/6323346023498926968?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/6323346023498926968?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/JXHZj-95NSY/take-picture-in-android-with.html" title="Take Picture in Android with MediaStore.ACTION_IMAGE_CAPTURE" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>12</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/10/take-picture-in-android-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEIFQno6cSp7ImA9WhRVF0s.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-4047940529604656711</id><published>2010-10-28T01:00:00.000+08:00</published><updated>2012-01-17T09:08:33.419+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-17T09:08:33.419+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Restart App" /><title>How to restart your own app in Android Tutorial</title><content type="html">After launching (now refactoring) Shoot and Learn [ &lt;a href="market://search?q=pname:com.almondmendoza.shootAndLearn"&gt;Market Link&lt;/a&gt; | &lt;a href="http://www.androidpit.com/en/android/market/apps/app/com.almondmendoza.shootAndLearn/Shoot-and-Learn"&gt;AndroidPit.com Link&lt;/a&gt; ] , its time to write what i have learn. &lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size:110%"&gt;Senario&lt;/strong&gt;&lt;br /&gt;
You want to restart your app because of some preference/setting changed, or you just want to restart your app.&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="color:red;font-size:110%"&gt;Notes&lt;/strong&gt;&lt;br /&gt;
This might not be the best solution thus if you have a better one kindly comment below :)&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size:110%"&gt;Introduction&lt;/strong&gt;&lt;br /&gt;
First we need our main activity to be a routing activity (if you came from the web, most framework do this where you have an index page where it routes other calls to its right controller). This main activity we shall call &lt;b&gt;PreMainActivity&lt;/b&gt;, in this tutorial we would only put the restart logic on this activity, you can put things like preloader, first run activity, etc.&lt;br /&gt;
&lt;br /&gt;
&lt;div class='amazonAssociates'&gt;Ads from Amazon: &lt;br /&gt;
&lt;a target="_blank"  href="http://www.amazon.com/Mobile-Phone-Programming-Application-Networking/dp/140205968X?ie=UTF8&amp;tag=monmonja05-20&amp;link_code=btl&amp;camp=213689&amp;creative=392969"&gt;Mobile Phone Programming: and its Application to Wireless Networking&lt;/a&gt;&lt;img src="http://www.assoc-amazon.com/e/ir?t=monmonja05-20&amp;l=btl&amp;camp=213689&amp;creative=392969&amp;o=1&amp;a=140205968X" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important; padding: 0px !important" /&gt;&lt;br /&gt;
&lt;/div&gt;&lt;br /&gt;
&lt;strong style="font-size:110%"&gt;What Do I Need&lt;/strong&gt;&lt;br /&gt;
&lt;i&gt;In Manafiest.xml&lt;/i&gt;&lt;br /&gt;
&lt;pre name="code" class="xml"&gt;&amp;lt;activity 
 android:name=".PreMainActivity"
 android:label="@string/app_name"
 android:launchMode="singleTop"
 android:configChanges="locale"
&gt;
 &amp;lt;intent-filter&gt;
  &amp;lt;action android:name="android.intent.action.MAIN" /&gt;
  &amp;lt;category android:name="android.intent.category.LAUNCHER" /&gt;
 &amp;lt;/intent-filter&gt;
&amp;lt;/activity&gt;
&amp;lt;activity android:name=".Main"
 android:configChanges="locale"
/&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;In PreMainActivity.java&lt;/i&gt;&lt;br /&gt;
&lt;pre name="code" class="java"&gt;public class PreMainActivity extends Activity {
 public static Boolean ENABLE_RESTART = false;
 
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  ENABLE_RESTART = true;
  restartMain();
 }
 
 @Override
 public void onRestart() {
  super.onRestart();
  restartMain();
 }
   
 public void restartMain(){
  if(ENABLE_RESTART == true){
   Intent mainIntent = new Intent(this, Main.class);
   mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP  );
   startActivity(mainIntent);
   finish();
  }else{
   finish();
  }
  ENABLE_RESTART   = false;
 }    
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;In your activity where you want to trigger the restart&lt;/i&gt;&lt;br /&gt;
&lt;code&gt;PreMainActivity.ENABLE_RESTART = true;&lt;br /&gt;
Intent i = new Intent(this,PreMainActivity.class);&lt;br /&gt;
i.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);&lt;br /&gt;
startActivity(i);&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size:110%"&gt;Explanation&lt;/strong&gt;&lt;br /&gt;
&lt;i style="color:#777"&gt;&amp;lt;activity &lt;br /&gt;&lt;br /&gt;
 android:name=".PreMainActivity" &lt;br /&gt;&lt;br /&gt;
.... /&gt;&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
As stated in our introduction we would use a PreMainActivity as the receiver of our main action.&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color:#777"&gt;public static Boolean ENABLE_RESTART = false;&lt;/i&gt;&lt;br /&gt;
In our activity we would have a static variable to check if the activity should restart or not.&lt;br /&gt;
 &lt;br /&gt;
&lt;i style="color:#777"&gt;@Override&lt;br /&gt;
public void onCreate(Bundle savedInstanceState) {&lt;br /&gt;
 super.onCreate(savedInstanceState);&lt;br /&gt;
 ENABLE_RESTART = true;&lt;br /&gt;
 restartMain();&lt;br /&gt;
}&lt;/i&gt;&lt;br /&gt;
When our app is first launched we would need to turn the flag to true in order for our next activity to restart/start.&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color:#777"&gt;Intent mainIntent = new Intent(this, Main.class);&lt;br /&gt;
mainIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP  );&lt;br /&gt;
startActivity(mainIntent);&lt;br /&gt;
finish();&lt;/i&gt;&lt;br /&gt;
With this code, i assumed that main is on the top of the activity stack therefore we could just relaunch it as clear the whole stack. See (&lt;a href="http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP"&gt;http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
&lt;i style="color:#777"&gt;PreMainActivity.ENABLE_RESTART = true;&lt;br /&gt;
Intent i = new Intent(this,PreMainActivity.class);&lt;br /&gt;
i.addFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);&lt;br /&gt;
startActivity(i);&lt;/i&gt;&lt;br /&gt;
Combined with &lt;b&gt;android:launchMode="singleTop"&lt;/b&gt; in our manifest file, we make sure that when we launch PreMainActivity we get a clear top, single top activity. Note I might be doing some redundancy on singletop flag.&lt;br /&gt;
&lt;br /&gt;
&lt;strong style="font-size:110%"&gt;Conclusion&lt;/strong&gt;&lt;br /&gt;
This how you can restart your app but this is not the best solution, as stated above im in a refactoring mode, in where instead of having a static variable, i would pass data &lt;i&gt;i.putExtra("RESTART", true);&lt;/i&gt; on the intent. Which is a better solution, but if you have any better idea please do comment below and ill try to be more active with this blog :)</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/4047940529604656711/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=4047940529604656711" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/4047940529604656711?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/4047940529604656711?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/Vj0yNTSs530/how-to-restart-your-own-app-in-android.html" title="How to restart your own app in Android Tutorial" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>3</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/10/how-to-restart-your-own-app-in-android.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkAAQHoyeSp7ImA9Wx5UEUo.&quot;"><id>tag:blogger.com,1999:blog-1193295309527347789.post-8604800354695036270</id><published>2010-10-16T03:25:00.000+08:00</published><updated>2010-10-16T03:25:41.491+08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-10-16T03:25:41.491+08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Shoot and Learn" /><title>Shoot and Learn</title><content type="html">After few months of developing an android app for fun, finally got to release one on the market :)&lt;br /&gt;
Firstly thanks to &lt;a href="http://katrina1204.blogspot.com/"&gt;SK Lam&lt;/a&gt; (his daugher's blog), to my parents for letting me stay late, to my friends for their suppor, to all who tested the app and to everyone that would download it.&lt;br /&gt;
&lt;br /&gt;
The app is an application for kids to learn objects around them by capturing it and learning it like flash cards. From the sound of that there shouldn't be anything special with the app right?&lt;br /&gt;
Yes and no, yes its a flash card app like other but no, it has a better UI and UX (i hope) and its colorful with different themes (Signs of being a frontend guy, ahah). &lt;br /&gt;
&lt;br /&gt;
Another interesting aspect is the Language feature (which i would like to open source it later when its ready), in here users can crowd source the language translation so that the translation of the app would be from its user base and thats the fun part of it :)&lt;br /&gt;
&lt;br /&gt;
There is still a lot of improvements on the app and on the codes level, so brace yourself for bugs.&lt;br /&gt;
&lt;br /&gt;
Head over the market place and search for "shoottolearn" &lt;-- easier to find it with this way&lt;br /&gt;
&lt;br /&gt;
Next blogs would be sharing the how to do on the apps. Any features on my app that you guys want me to blog? Comment down below. Thanks</content><link rel="replies" type="application/atom+xml" href="http://www.tutorialforandroid.com/feeds/8604800354695036270/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1193295309527347789&amp;postID=8604800354695036270" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/8604800354695036270?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1193295309527347789/posts/default/8604800354695036270?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/TutorialForAndroid/~3/KkMpSIwv2_8/shoot-and-learn.html" title="Shoot and Learn" /><author><name>Almond Joseph Mendoza</name><uri>https://plus.google.com/101518860229446899809</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="32" src="//lh6.googleusercontent.com/-vu8S-gipxJo/AAAAAAAAAAI/AAAAAAACEpI/v2iCsG_euBY/s512-c/photo.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.tutorialforandroid.com/2010/10/shoot-and-learn.html</feedburner:origLink></entry></feed>
