<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" 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" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-4560389092782236816</atom:id><lastBuildDate>Wed, 06 Nov 2024 02:57:57 +0000</lastBuildDate><category>Android Basics</category><category>Android Projects</category><category>Flashlight</category><category>Flick Cam</category><category>Form</category><category>Tips &amp; Tricks</category><category>array adapter</category><category>list adapter</category><category>setListAdapter</category><category>AVD</category><category>AlarmManager</category><category>Alert Dialog</category><category>Android Activity LifeCycle</category><category>Android Database Part I</category><category>Android Database Part II</category><category>Android List View Part 2</category><category>Android List view Part 1</category><category>Android List view Part 3</category><category>AppWidgetProvider</category><category>Battery stat</category><category>Broadcast Receiver</category><category>Button</category><category>Canvas</category><category>Compile statement</category><category>Custom Adapter</category><category>Custom View</category><category>Custom button</category><category>Database</category><category>Digital Clock</category><category>Email Validation</category><category>Erase canvas</category><category>First App</category><category>Form Verification</category><category>Grid View</category><category>Hash map</category><category>Hello World</category><category>IDE</category><category>Insert in database</category><category>Install Eclipse</category><category>Install JDK</category><category>Intent extras</category><category>MediaPlayer</category><category>MediaScannerConnection</category><category>Menu inflator</category><category>MenuInflator</category><category>MotionEvent</category><category>Notification</category><category>Paint</category><category>Path</category><category>Pattern Matching</category><category>Pen</category><category>PowerManager</category><category>Query Optimization</category><category>Remove from database</category><category>Retrieve from database</category><category>Reuse Views</category><category>Reuse layout</category><category>SDK Updates</category><category>Sign It! part 2</category><category>Sign It! part 3</category><category>String.format</category><category>StringBuilder</category><category>TextView</category><category>Transactions</category><category>Update database</category><category>View Holder</category><category>Wake Lock</category><category>gallery</category><category>getView</category><category>google</category><category>invalidate()</category><category>launch app</category><category>life cycle</category><category>save canvas</category><category>save to gallery</category><category>setTag</category><category>widgets</category><title>roadtodroid</title><description>The Fast Lane To Android</description><link>http://roadtodroid.blogspot.com/</link><managingEditor>noreply@blogger.com (Anonymous)</managingEditor><generator>Blogger</generator><openSearch:totalResults>17</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-1217603934918908604</guid><pubDate>Tue, 03 Feb 2015 11:27:00 +0000</pubDate><atom:updated>2015-02-03T03:28:05.748-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Flick Cam</category><title>Flick Cam on Play Store</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPcuXcsVIeUzqT9L2WiwMbYruIhb7LrGDaCnExKo2IuUfjgdWg5IUipSUg6yWAcyuItN0AU8QsxnciJhPpeTw1laqmnMT7NsAgw8j9xPLTacj7hxSpn3XuzH80Jd8n0QstDBEyVJuTu-4/s1600/feature-graphic.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPcuXcsVIeUzqT9L2WiwMbYruIhb7LrGDaCnExKo2IuUfjgdWg5IUipSUg6yWAcyuItN0AU8QsxnciJhPpeTw1laqmnMT7NsAgw8j9xPLTacj7hxSpn3XuzH80Jd8n0QstDBEyVJuTu-4/s1600/feature-graphic.png&quot; height=&quot;195&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Download my app the Flick Cam from &amp;nbsp;Play Store using the link below:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://play.google.com/store/apps/details?id=in.blogdpot.r2d.com.flip_control&quot;&gt;https://play.google.com/store/apps/details?id=in.blogdpot.r2d.com.flip_control&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Enjoy the app and Rate it.&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2015/02/flick-cam-on-play-store.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjPcuXcsVIeUzqT9L2WiwMbYruIhb7LrGDaCnExKo2IuUfjgdWg5IUipSUg6yWAcyuItN0AU8QsxnciJhPpeTw1laqmnMT7NsAgw8j9xPLTacj7hxSpn3XuzH80Jd8n0QstDBEyVJuTu-4/s72-c/feature-graphic.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-7813711311027988128</guid><pubDate>Sat, 31 Jan 2015 03:15:00 +0000</pubDate><atom:updated>2015-01-30T19:18:07.369-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Flick Cam</category><title>Launching Flick Cam app</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;color: #351c75;&quot;&gt;Flick Cam&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgimD1onhPKj2bxwI35i9y0OmaOqUmGW_9AkYzzuKSAluuNFJxfTdqX9k8DEDfFYfcbYyWrUHxO-DdOZ3PhSx_bMfsdpgIFRzYppKB_EBRD1RpHdLNSCtlw8iuzvj9kzY15FihmzRUYWjY/s1600/feature-graphic.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgimD1onhPKj2bxwI35i9y0OmaOqUmGW_9AkYzzuKSAluuNFJxfTdqX9k8DEDfFYfcbYyWrUHxO-DdOZ3PhSx_bMfsdpgIFRzYppKB_EBRD1RpHdLNSCtlw8iuzvj9kzY15FihmzRUYWjY/s1600/feature-graphic.png&quot; height=&quot;312&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
This is the Flick Cam app, which is going to be my first app on the Play Store. The app is still in alpha version, so it will take time to release. Stay tuned for updates.&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
To apply for alpha testing send a request to ;-&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;mailto:flick-cam-alpha@googlegroups.com&quot;&gt;flick-cam-alpha@googlegroups.com&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2015/01/launching-flick-cam-app.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgimD1onhPKj2bxwI35i9y0OmaOqUmGW_9AkYzzuKSAluuNFJxfTdqX9k8DEDfFYfcbYyWrUHxO-DdOZ3PhSx_bMfsdpgIFRzYppKB_EBRD1RpHdLNSCtlw8iuzvj9kzY15FihmzRUYWjY/s72-c/feature-graphic.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-1736041344272854132</guid><pubDate>Sat, 03 Jan 2015 06:50:00 +0000</pubDate><atom:updated>2015-01-03T08:45:04.231-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Projects</category><category domain="http://www.blogger.com/atom/ns#">Battery stat</category><category domain="http://www.blogger.com/atom/ns#">Broadcast Receiver</category><category domain="http://www.blogger.com/atom/ns#">Flashlight</category><category domain="http://www.blogger.com/atom/ns#">Notification</category><title>Flashlight Part II (BatteryStats and Notifications)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;background-color: white; border: 0px; color: #777777; font-family: Roboto, sans-serif; font-size: 27px; font-stretch: inherit; margin: 0px 0px 0.6em; padding: 0px; position: relative; text-align: center; vertical-align: baseline;&quot;&gt;
&lt;u style=&quot;border: 0px; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;border: 0px; color: #444444; font-family: &#39;Trebuchet MS&#39;, sans-serif; font-size: large; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;FlashLight Part II&lt;/span&gt;&lt;/u&gt;&lt;/h2&gt;
&lt;h3 style=&quot;background-color: white; border: 0px; color: #777777; font-family: Roboto, sans-serif; font-size: 24px; font-stretch: inherit; margin: 0px 0px 0.6em; padding: 0px; position: relative; text-align: center; vertical-align: baseline;&quot;&gt;
&lt;span style=&quot;border: 0px; color: #444444; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(Battery Stats and Notifications)&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL1jBXKyAIiV8Lm8YpT0tivdE-0f1Tq-JYWiCCGExXdXyaRxwa_rO6_fSfUit4y2T6QBudkeQS9FQbfi2pDCKYtDtqwyx5E0PKn8O2obNsUksl2ciKcg8RD1cN04DVkftwapPlj7BSYkc/s1600/flashlight_logo_mark.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL1jBXKyAIiV8Lm8YpT0tivdE-0f1Tq-JYWiCCGExXdXyaRxwa_rO6_fSfUit4y2T6QBudkeQS9FQbfi2pDCKYtDtqwyx5E0PKn8O2obNsUksl2ciKcg8RD1cN04DVkftwapPlj7BSYkc/s1600/flashlight_logo_mark.png&quot; height=&quot;480&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;border: 0px; color: #444444; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;border: 0px; color: #444444; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
Picking up from where we left from &amp;nbsp;&lt;a href=&quot;http://roadtodroid.blogspot.in/2014/12/flashlight-part-i-working-with-flash.html&quot;&gt;Part I&lt;/a&gt;, we are going to add some pretty cool design elements to the UI. It&#39;s quite simplistic and just shows the battery stats to the user so as to notify him/her about the battery percentage and temperature etc. Also we implement Notifications for the app so it can notify the user about whether the light is on or off. So let&#39;s begin with designing part first.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;1. Add three TextViews to the layout from &lt;a href=&quot;http://roadtodroid.blogspot.in/2014/12/flashlight-part-i-working-with-flash.html&quot;&gt;PartI&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Drag and drop three text views in the Graphical Layout of the app (activity_main.xml).&lt;/li&gt;
&lt;li&gt;Edit the xml as shown below.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5zjzGKFeWHgd2NF_GFC-qdRloIMrjw56qWUfYuEgMkMA-V7pqZ_dtjLu2X3s9ctF7CZ-G_478xm8yr49RX-rFIgNLgHW3w94-i0B7MIDMKORuq_kUcPc2D5JFh37lZYtwx0qFglMopuw/s1600/layout.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5zjzGKFeWHgd2NF_GFC-qdRloIMrjw56qWUfYuEgMkMA-V7pqZ_dtjLu2X3s9ctF7CZ-G_478xm8yr49RX-rFIgNLgHW3w94-i0B7MIDMKORuq_kUcPc2D5JFh37lZYtwx0qFglMopuw/s1600/layout.PNG&quot; height=&quot;400&quot; width=&quot;240&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;App layout&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/f691fbfb7c53febc4ef8.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;2. Changes to the Manifest file&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the Manifest file of the previous part we make our activity launchMode as &lt;span style=&quot;color: #990000;&quot;&gt;singleTask. &lt;/span&gt;This is required as we are going to implement the same activity as the Pending Intent to our Notification.&lt;/li&gt;
&lt;li&gt;In the activity tag of the manifest file add the line -&amp;nbsp;&amp;nbsp;&lt;span style=&quot;color: #cc0000;&quot;&gt;android:launchMode&lt;/span&gt;=&quot;&lt;span style=&quot;color: #0b5394;&quot;&gt;singleTask&lt;/span&gt;&quot;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/8081e44cf43d4b59eb7e.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;3. Display a Notification&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;To display a notification when the on button is pressed use the following function in the OnClickListner of the button.&lt;/li&gt;
&lt;li&gt;The function uses the&amp;nbsp;&lt;span class=&quot;pl-stj&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;NotificationCompat&lt;/span&gt;&lt;span class=&quot;pl-k&quot; style=&quot;background-color: white; box-sizing: border-box; color: #a71d5d; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pl-stj&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;Builder &lt;/span&gt;class to create a notification.&lt;/li&gt;
&lt;li&gt;The Pending Intent class is used to create a link to the same class (MainActivity) &amp;nbsp;when the notification is clicked on.&lt;/li&gt;
&lt;li&gt;Finally the&amp;nbsp;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;number_notifications &lt;/span&gt;variable is used to count the number of notification are there.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/0ea7b5c0fe2556701bd9.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;4. Cancel a Notification or all of them&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/5c534192f889964273a9.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;5. Create a Broadcast Receiver for battery stats&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/5aee387ede9343678eb0.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;6. MainActivity.java file&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/064a0ca8e1dbd3fc3348.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjmN_EmLA_7uC3McO-ogLyjCkYPBRC8WX7dfONd1o_mB-wJKXCYvEnUvnh-iMVnxfrR5OkhoKVJwBk_KVpqquZf8RoPjREb1KpGxYpszdRMbguZWd_LkGjnjaTp3VHp0fsiJCsNlEEK3A/s1600/flashlight+part+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjmN_EmLA_7uC3McO-ogLyjCkYPBRC8WX7dfONd1o_mB-wJKXCYvEnUvnh-iMVnxfrR5OkhoKVJwBk_KVpqquZf8RoPjREb1KpGxYpszdRMbguZWd_LkGjnjaTp3VHp0fsiJCsNlEEK3A/s1600/flashlight+part+2.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #e69138;&quot;&gt;Download Code&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvoS_z5UZVuhUwuQI5S4inwVvbnqB-bh5mOjSCdnp1IswnC3k7C3Wbz0RnuXO2OkJmcgv9tHJr0GYIjbL4iH567OnBuH1B8eXCVlSmPVpZL7-25735w4kwIqfxTxbXi1jH0fJ6ZUSX7Ts/s1600/ic_cloud_download_black_48dp.png&quot; height=&quot;200&quot; href=&quot;https://www.dropbox.com/sh/0f0zvw1jw57d0gc/AAACUPmoMMSmeRxLTvuUUoB-a?dl=1&quot; width=&quot;200&quot; /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;http://roadtodroid.blogspot.in/2014/12/flashlight-part-i-working-with-flash.html&quot;&gt;&lt;span style=&quot;color: #990000;&quot;&gt;Goto Part I&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2015/01/flashlight-part-ii-batterystats-and.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhL1jBXKyAIiV8Lm8YpT0tivdE-0f1Tq-JYWiCCGExXdXyaRxwa_rO6_fSfUit4y2T6QBudkeQS9FQbfi2pDCKYtDtqwyx5E0PKn8O2obNsUksl2ciKcg8RD1cN04DVkftwapPlj7BSYkc/s72-c/flashlight_logo_mark.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-94784911692849136</guid><pubDate>Fri, 26 Dec 2014 17:42:00 +0000</pubDate><atom:updated>2015-01-03T08:38:18.392-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Projects</category><category domain="http://www.blogger.com/atom/ns#">Custom button</category><category domain="http://www.blogger.com/atom/ns#">Flashlight</category><category domain="http://www.blogger.com/atom/ns#">MediaPlayer</category><title>Flashlight Part I (Working with flash)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: center;&quot;&gt;
&lt;u&gt;&lt;span style=&quot;color: #444444; font-family: Trebuchet MS, sans-serif; font-size: x-large;&quot;&gt;FlashLight Part I&lt;/span&gt;&lt;/u&gt;&lt;/h2&gt;
&lt;h3 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;(Working with Camera Flash and MediaPlayer sounds)&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2j1NVgbAASIz-SLeCbeG46y-kZMQwfGtTvjL9Pow_YQTtzsJnT8rBCwETnXY8l9weR3WLubLWffleOh_Mpr5UP_qYD3gT2M-6T9si9fqUAuCpyJvagi5oD9SnF5sJipE4flcqOhebig8/s1600/flashlight_logo_mark.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2j1NVgbAASIz-SLeCbeG46y-kZMQwfGtTvjL9Pow_YQTtzsJnT8rBCwETnXY8l9weR3WLubLWffleOh_Mpr5UP_qYD3gT2M-6T9si9fqUAuCpyJvagi5oD9SnF5sJipE4flcqOhebig8/s1600/flashlight_logo_mark.png&quot; height=&quot;480&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;u&gt;&lt;span style=&quot;color: #444444; font-family: Trebuchet MS, sans-serif; font-size: x-large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/u&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Hi everyone and welcome to another fun Android project at roadtodroid. This time we are going to make a Flash light app which is very easy and fun to make. I am going to complete this app in two parts, first with only the basic app with only flash and second with notifications and all other battery related stats. So stay tuned for part 2 and hope you like the post.&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;1. Create a new Android Application Project&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;li&gt;Give appropriate name for the project and move forward (I&#39;m using API 19 for this project).&lt;/li&gt;
&lt;li&gt;In the succeeding dialogs just click next and make sure to create an Empty Activity name MainActivity.java or of any name you want.&lt;/li&gt;
&lt;li&gt;Finally click finish.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;2. Design the layout of the App&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open res &amp;gt; layout &amp;gt; activity_main.xml.&lt;/li&gt;
&lt;li&gt;Add one Button to it, as shown below.&lt;/li&gt;
&lt;li&gt;Use the code provided to format the elements.&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaGAJMaPM_aEzD424e9TFqQfBFfn5mP6RaV2IneVw8YopDErp1tA_y5mOreMWHVjEUBd-hKfDb5cw66pS08CrD4bymupXcs-APrVN23_bmtehKNLCraK5-9DDOOjOaiHwoQi1Kcu84gTc/s1600/layout1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaGAJMaPM_aEzD424e9TFqQfBFfn5mP6RaV2IneVw8YopDErp1tA_y5mOreMWHVjEUBd-hKfDb5cw66pS08CrD4bymupXcs-APrVN23_bmtehKNLCraK5-9DDOOjOaiHwoQi1Kcu84gTc/s1600/layout1.PNG&quot; height=&quot;400&quot; width=&quot;233&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;App layout&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/671bfa991ecbee0da404.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;3. Design the Button Background&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;For designing our custom button we use a xml&amp;nbsp;&lt;span style=&quot;color: #38761d;&quot;&gt;&lt;selector&gt;.&amp;nbsp;&lt;/selector&gt;&lt;/span&gt;All xmls here are in res/drawable folder.&lt;/li&gt;
&lt;li&gt;The selector defines three items which are for state_focused=&quot;&lt;span style=&quot;color: #990000;&quot;&gt;true&lt;/span&gt;&quot; ,state_focused=&quot;&lt;span style=&quot;color: #990000;&quot;&gt;false&lt;/span&gt;&quot;and default state.&lt;/li&gt;
&lt;li&gt;Custom drawables are used to make circular button and with given width and stroke.&lt;/li&gt;
&lt;li&gt;The examples are as below.&lt;/li&gt;
&lt;li&gt;For more download the code and see the res &amp;gt; drawable-hdpi folder.&lt;/li&gt;
&lt;li&gt;To add the xml with selector to our button background use &lt;span style=&quot;color: #660000;&quot;&gt;android:background&lt;/span&gt;=&quot;&lt;span style=&quot;color: #3d85c6;&quot;&gt;@drawable/multi_buttom.xml&lt;/span&gt;&quot;.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/9cf5669a2290555930b0.js&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/7ffc17225fe3fe243720.js&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;4. Adding Sounds to the button&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Add the sounds you like in the res &amp;gt; raw folder (if not there create a new one).&lt;/li&gt;
&lt;li&gt;Then use the MediaPlayer class as shown in the code below.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/9616180add8cee3601ea.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;5. Lets move to the coding part&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the Manifest file add the following permission-&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #38761d;&quot;&gt;&amp;nbsp;&lt;uses-permission font=&quot;&quot;&gt; &lt;span style=&quot;color: #990000;&quot;&gt;android:name&lt;/span&gt;=&quot;&lt;span style=&quot;color: #134f5c;&quot;&gt;android.permission.CAMERA&lt;/span&gt;&quot; &lt;span style=&quot;color: #38761d;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/uses-permission&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In MainActivity.java in the onCreate method, bind the button to its layout counterpart using &lt;span style=&quot;color: #783f04;&quot;&gt;findViewById &lt;/span&gt;and set an OnClickListner for it.&lt;/li&gt;
&lt;li&gt;In the OnClickListner, check for the availability of flash light on the device using getPackerManager().hasSystemFeature(PackageManager.&lt;span style=&quot;color: #45818e;&quot;&gt;FEATURE_CAMERA_FLASH&lt;/span&gt;).&lt;/li&gt;
&lt;li&gt;We create methods each for playing sound on button pressed , changing button layout, getting the camera and releasing camera.All these are as shown below.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/a6c4e67b48480fc26224.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #741b47;&quot;&gt;&amp;nbsp;Stay tuned for &lt;a href=&quot;https://www.blogger.com/&quot;&gt;Part 2&lt;span id=&quot;goog_1971337432&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;span style=&quot;color: #134f5c;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;510&quot; src=&quot;//www.youtube.com/embed/tozlGh5zR8g&quot; width=&quot;854&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/12/flashlight-part-i-working-with-flash.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2j1NVgbAASIz-SLeCbeG46y-kZMQwfGtTvjL9Pow_YQTtzsJnT8rBCwETnXY8l9weR3WLubLWffleOh_Mpr5UP_qYD3gT2M-6T9si9fqUAuCpyJvagi5oD9SnF5sJipE4flcqOhebig8/s72-c/flashlight_logo_mark.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-2048527755388874859</guid><pubDate>Thu, 11 Dec 2014 16:09:00 +0000</pubDate><atom:updated>2014-12-15T11:10:32.987-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">AlarmManager</category><category domain="http://www.blogger.com/atom/ns#">Android Projects</category><category domain="http://www.blogger.com/atom/ns#">AppWidgetProvider</category><category domain="http://www.blogger.com/atom/ns#">Digital Clock</category><category domain="http://www.blogger.com/atom/ns#">PowerManager</category><category domain="http://www.blogger.com/atom/ns#">Wake Lock</category><category domain="http://www.blogger.com/atom/ns#">widgets</category><title>THE CLOCK WIDGET</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjR0oDo408k4YAoaNrq5zY8xpAOS3CMbwQCiHX17B5rXWNXljwphh6fpYDkOwjkfE_tPzw0GVse4LlcbzklmtcDqLPJwi3pi9eFQvkShxIv5rQsCgtVrWspNceNfSuyGxghyphenhyphenYO_QL3lNhU/s1600/Screenshot_2014-12-11-22-12-40.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjR0oDo408k4YAoaNrq5zY8xpAOS3CMbwQCiHX17B5rXWNXljwphh6fpYDkOwjkfE_tPzw0GVse4LlcbzklmtcDqLPJwi3pi9eFQvkShxIv5rQsCgtVrWspNceNfSuyGxghyphenhyphenYO_QL3lNhU/s1600/Screenshot_2014-12-11-22-12-40.png&quot; height=&quot;384&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: center;&quot;&gt;
&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;background-color: #f9cb9c;&quot;&gt;&lt;span style=&quot;color: #741b47;&quot;&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;THE CLOCK WIDGET&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Sup everyone! Happy Holiday to all.This time r2d is back with another cool android project. We are going to make a digital clock widget of our own. Isn&#39;t that cool!&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Note that Android has an in-built Digital Clock widget in its layouts , but we want more customization so we are implementing our own version of it. So let&#39;s roll.&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #0c343d;&quot;&gt;1. Create a new Android Application Project&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;li&gt;Complete the wizard and create a new Activity (MainActivity.java).&lt;/li&gt;
&lt;li&gt;In the activity_main.xml file under res/layout, create two TextView s to be used to show time and date.&lt;/li&gt;
&lt;li&gt;The code and the resulting layout will be like this-&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/8e54f606cae24e7eda5c.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6lDj6uLy6TwcfT1FHmAJLHxYngs78UmEJ8GO4wOgQMCbJcvbBmO1iWVDcjGkqAziEKyNSgJfKnAgKfige9ibH3CZcYtOBAcK_dKM9HUAjIfeSpMizyXZz2UcmpPCx-OwTWNQQu9Rg11c/s1600/layout.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6lDj6uLy6TwcfT1FHmAJLHxYngs78UmEJ8GO4wOgQMCbJcvbBmO1iWVDcjGkqAziEKyNSgJfKnAgKfige9ibH3CZcYtOBAcK_dKM9HUAjIfeSpMizyXZz2UcmpPCx-OwTWNQQu9Rg11c/s1600/layout.PNG&quot; height=&quot;320&quot; width=&quot;190&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Layout of the widget&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h3 style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/h3&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #0c343d;&quot;&gt;2. Add a new AppWidgetProvider resource to res/xml&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Create the res/xml folder if not available already.&lt;/li&gt;
&lt;li&gt;Add a new xml to this folder and name it widget_xml.xml (or anything you like).&lt;/li&gt;
&lt;li&gt;Add the code given below to the xml file.The Structure is also shown if figure below.&lt;/li&gt;
&lt;li&gt;The fields are as described below:&lt;/li&gt;
&lt;/ul&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Min Width/Height - min. width/height with which the widget will be drawn.&lt;/li&gt;
&lt;li&gt;Min. Resize Width/Height - width/height to which it can be re-sized.&lt;/li&gt;
&lt;li&gt;Initial layout - the layout which is used to draw the widget.&lt;/li&gt;
&lt;li&gt;Resize Mode - &amp;nbsp;direction in which re-size is allowed.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/d9c61c2c274af990a8aa.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3szYjvouS9ERDbi7aNODGBBdxavxUGTxYa07gBDr263eATKTB2P8ES26ut3oSOPpdstJf20vbJoz2sQ-mxdctDc9ODwndUyMgbPF-QrW9Gs-c95NNZLfd4COXPOsUVCOoHiwuC9r_a8Q/s1600/app_widget_provider.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg3szYjvouS9ERDbi7aNODGBBdxavxUGTxYa07gBDr263eATKTB2P8ES26ut3oSOPpdstJf20vbJoz2sQ-mxdctDc9ODwndUyMgbPF-QrW9Gs-c95NNZLfd4COXPOsUVCOoHiwuC9r_a8Q/s1600/app_widget_provider.PNG&quot; height=&quot;334&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Fields in the AppWidgetProvider&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h3 style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/h3&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #0c343d;&quot;&gt;3. Make changes to the Manifest XML&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Add the following permissions the manifest file as they will be used to access some features of Android system later while coding.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;line-pre&quot; style=&quot;box-sizing: border-box; width: 748px;&quot;&gt;&lt;div class=&quot;line&quot; id=&quot;file-manifest-xml-LC11&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; text-align: left;&quot;&gt;
&lt;span style=&quot;line-height: 16.7999992370605px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pl-ent&quot; style=&quot;box-sizing: border-box; color: #63a35c; line-height: 16.7999992370605px;&quot;&gt;uses-permission&lt;/span&gt;&lt;span style=&quot;line-height: 16.7999992370605px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pl-e&quot; style=&quot;box-sizing: border-box; color: #795da3; line-height: 16.7999992370605px;&quot;&gt;android&lt;/span&gt;&lt;span class=&quot;pl-e&quot; style=&quot;box-sizing: border-box; color: #795da3; line-height: 16.7999992370605px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pl-e&quot; style=&quot;box-sizing: border-box; color: #795da3; line-height: 16.7999992370605px;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;line-height: 16.7999992370605px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-s1&quot; style=&quot;box-sizing: border-box; color: #df5000; line-height: 16.7999992370605px;&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;com.android.alarm.permission.SET_ALARM&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 16.7999992370605px;&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;line-height: 16.7999992370605px;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pl-ent&quot; style=&quot;box-sizing: border-box; color: #63a35c; line-height: 16.7999992370605px;&quot;&gt;uses-permission&lt;/span&gt;&lt;span style=&quot;line-height: 16.7999992370605px;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pl-e&quot; style=&quot;box-sizing: border-box; color: #795da3; line-height: 16.7999992370605px;&quot;&gt;android&lt;/span&gt;&lt;span class=&quot;pl-e&quot; style=&quot;box-sizing: border-box; color: #795da3; line-height: 16.7999992370605px;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pl-e&quot; style=&quot;box-sizing: border-box; color: #795da3; line-height: 16.7999992370605px;&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;line-height: 16.7999992370605px;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pl-s1&quot; style=&quot;box-sizing: border-box; color: #df5000; line-height: 16.7999992370605px;&quot;&gt;&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;android.permission.WAKE_LOCK&lt;span class=&quot;pl-pds&quot; style=&quot;box-sizing: border-box;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;line-height: 16.7999992370605px;&quot;&gt; /&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;line-pre&quot; style=&quot;box-sizing: border-box; width: 748px;&quot;&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Remove the &amp;lt;&lt;span style=&quot;background-color: white; color: #63a35c; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;activity&amp;gt;&lt;/span&gt;&amp;nbsp;tag from your &amp;nbsp;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;pl-ent&quot; style=&quot;background-color: white; box-sizing: border-box; color: #63a35c; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;application&amp;gt; &lt;/span&gt;tag as our app doesn&#39;t implement an activity.Instead add a receiver for the widget as shown below:-&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/b96874bc0ecd4e9a1abf.js&quot;&gt;&lt;/script&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE7wJFSQyHO4wEy3oSSs8hUzcKDTXvtMpR9tCY__LV61_PAZY7ejA2D8vFvQO19X88aKngRhsznQD7CPlQgYLEngrMNOBgjf0z-6JToV1myDsrhn6Uy8Iy4oxQ1GGRS97ZqSAEWZJrK7Q/s1600/project.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiE7wJFSQyHO4wEy3oSSs8hUzcKDTXvtMpR9tCY__LV61_PAZY7ejA2D8vFvQO19X88aKngRhsznQD7CPlQgYLEngrMNOBgjf0z-6JToV1myDsrhn6Uy8Iy4oxQ1GGRS97ZqSAEWZJrK7Q/s1600/project.PNG&quot; height=&quot;400&quot; width=&quot;152&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Final view of the Project Explorer&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;h2 style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;
&lt;span style=&quot;color: #0c343d;&quot;&gt;4. Code the MainActivity&lt;/span&gt;&lt;/h2&gt;
&lt;ul style=&quot;font-family: &#39;Times New Roman&#39;; text-align: left; white-space: normal;&quot;&gt;
&lt;li&gt;The MainActivity extends &lt;span style=&quot;color: #0b5394;&quot;&gt;AppWidgetProvider&lt;/span&gt; so that it can use the services of the Android API.&lt;/li&gt;
&lt;li&gt;The various methods such as &lt;span style=&quot;color: #a64d79;&quot;&gt;OnReceive()&lt;/span&gt;, &lt;span style=&quot;color: #a64d79;&quot;&gt;OnUpdate()&lt;/span&gt; , &lt;span style=&quot;color: #a64d79;&quot;&gt;OnEnabled()&lt;/span&gt;, &lt;span style=&quot;color: #a64d79;&quot;&gt;OnDisabled()&lt;/span&gt; of the AppWidgetProvider are overridden , to apply widget life cycle methods.&lt;/li&gt;
&lt;li&gt;More in the last section.&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;font-family: Times New Roman;&quot;&gt;&lt;span style=&quot;white-space: normal;&quot;&gt;&lt;a href=&quot;https://gist.github.com/shobhitchittora/ae6505c3553beaddbda5&quot;&gt;MainActivity.java&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h2 style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;
&lt;span style=&quot;color: #0c343d;&quot;&gt;--Code Explained --&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit; white-space: normal;&quot;&gt;The OnReceive() method is called when the widget receives call to update its contents. Here we get all the id(s) for all the instances of our widget , and call updatetime() method the we defined, to update time in every instance.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit; white-space: normal;&quot;&gt;The createClockIntent() method is used by the AlarmManager to send a pending Intent to our widget every 1000 msec. &lt;span style=&quot;color: #660000;&quot;&gt;The Android system only allows to update a widget every 30min (due to several reasons). So we use Alarm Manager to update it each second.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit; white-space: normal;&quot;&gt;The OnEnabled() method is used to start the Alarm Manger and the method OnDisabled() is where the timer is disabled.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit; white-space: normal;&quot;&gt;Finally in the OnUpdate() method we acquire a Wake Lock, to keep the CPU on (Note that this is not necessary here ,but I thought to show it&#39;s use here). the it uses RemoteViews to send Pending Intent to each TextView to open ALARM Intent. Finally the Wake Lock is released.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: inherit; white-space: normal;&quot;&gt;The updatetime() method is just filling the TextViews with the required time and date.&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #073763;&quot;&gt;Download Code&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/oxqiidui387gu7a/AABu6Q0rCveB9e5WMOfvBYOFa?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvoS_z5UZVuhUwuQI5S4inwVvbnqB-bh5mOjSCdnp1IswnC3k7C3Wbz0RnuXO2OkJmcgv9tHJr0GYIjbL4iH567OnBuH1B8eXCVlSmPVpZL7-25735w4kwIqfxTxbXi1jH0fJ6ZUSX7Ts/s1600/ic_cloud_download_black_48dp.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h3 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #8e7cc3;&quot;&gt;SCREENSHOTS&lt;/span&gt;&lt;/h3&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBVjCN-OPuC6Hbi7Lg-sYDB2cH__Dzsh6wXim6XduI6Qfjp2RB0pBN1KddYgrOfkgClPbGJ900x_Y_Gg3grStPfIiL1peXsI7mJj1IxlSZgK0j5nChTIAP3phfMQsf11zlYafYGO_ZI-g/s1600/DFG_2014-12-15-22-55-14.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBVjCN-OPuC6Hbi7Lg-sYDB2cH__Dzsh6wXim6XduI6Qfjp2RB0pBN1KddYgrOfkgClPbGJ900x_Y_Gg3grStPfIiL1peXsI7mJj1IxlSZgK0j5nChTIAP3phfMQsf11zlYafYGO_ZI-g/s1600/DFG_2014-12-15-22-55-14.png&quot; height=&quot;320&quot; width=&quot;191&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj133qC7hsnlvx1DJlshC_C27ZtzjxKtkRWMwyWLz_G-Xl5E4nxPYbM9AQKKBQxbmDmYVWqbsf5z5Fi8ICc2LVfd-CWB6nJ3nciIEXfY2cTAiivcvsPlytIhJgzqbxiOeDhggEsEl0FiS4/s1600/DFG_2014-12-15-22-56-39.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj133qC7hsnlvx1DJlshC_C27ZtzjxKtkRWMwyWLz_G-Xl5E4nxPYbM9AQKKBQxbmDmYVWqbsf5z5Fi8ICc2LVfd-CWB6nJ3nciIEXfY2cTAiivcvsPlytIhJgzqbxiOeDhggEsEl0FiS4/s1600/DFG_2014-12-15-22-56-39.png&quot; height=&quot;320&quot; width=&quot;191&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8THSm1lvDc2IWoA4FpoDOWCDNQNIAn9EwMyoOar4tY3UHtDL89gicedGfiBKQVMPu4MPoJP-WeeD3McZizoZQd9RFdlqbwUXljbOw_lWc0nqynLCno93rr9CX2AmoOMe57RdPudCT1B0/s1600/DFG_2014-12-15-22-55-21.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8THSm1lvDc2IWoA4FpoDOWCDNQNIAn9EwMyoOar4tY3UHtDL89gicedGfiBKQVMPu4MPoJP-WeeD3McZizoZQd9RFdlqbwUXljbOw_lWc0nqynLCno93rr9CX2AmoOMe57RdPudCT1B0/s1600/DFG_2014-12-15-22-55-21.png&quot; height=&quot;320&quot; width=&quot;191&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/12/the-clock-widget.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjR0oDo408k4YAoaNrq5zY8xpAOS3CMbwQCiHX17B5rXWNXljwphh6fpYDkOwjkfE_tPzw0GVse4LlcbzklmtcDqLPJwi3pi9eFQvkShxIv5rQsCgtVrWspNceNfSuyGxghyphenhyphenYO_QL3lNhU/s72-c/Screenshot_2014-12-11-22-12-40.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-8188946412938749715</guid><pubDate>Fri, 28 Nov 2014 18:17:00 +0000</pubDate><atom:updated>2014-11-28T10:17:02.246-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Alert Dialog</category><category domain="http://www.blogger.com/atom/ns#">Android Projects</category><category domain="http://www.blogger.com/atom/ns#">Hash map</category><category domain="http://www.blogger.com/atom/ns#">Sign It! part 3</category><title>SignIt! Part III (Alert Dialog and HashMap )</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZKy68R_M7LW_509sLclKdfYRTs9l7Iu1Z1nUX42xRIfHw3wRgnhex6XIgWvCVVlnpwAOGFcKv87jNI0muRpLaB8YFIYwYWFxBrTdo62zZz_NdBfFV4NWN2LddxJusCMfBqcv7RKIwzNA/s1600/sign+it+part+3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZKy68R_M7LW_509sLclKdfYRTs9l7Iu1Z1nUX42xRIfHw3wRgnhex6XIgWvCVVlnpwAOGFcKv87jNI0muRpLaB8YFIYwYWFxBrTdo62zZz_NdBfFV4NWN2LddxJusCMfBqcv7RKIwzNA/s1600/sign+it+part+3.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #741b47;&quot;&gt;SIGN IT PART III&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
Hey everyone! Welcome to the final part of the Sign It series. In this section we will add the functionality to let the user select the stroke width and color of the paint object. Also the method of saving different styled paths to the bitmap is also demonstrated.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Before moving any further, it&#39;s highly recommended to go through the previous pars of the series for the basic code. Let&#39;s go now.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;1. Add the function to change the Stroke Width&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Add this function in our &lt;span style=&quot;color: #0b5394;&quot;&gt;CanvasView.java&lt;/span&gt; class.&lt;/li&gt;
&lt;li&gt;In this function we create an AlertDialog using &lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;a href=&quot;http://developer.android.com/reference/android/app/AlertDialog.Builder.html&quot;&gt;AlertDialog.Builder&lt;/a&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;The &lt;span style=&quot;color: #3d85c6;&quot;&gt;setPositiveButton() &lt;/span&gt;is used to add the &quot;OK&quot; button to the dialog. In the same way a negative or &quot;Cancel&quot; button can be added using &lt;span style=&quot;color: #3d85c6;&quot;&gt;setNegativeButton()&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;setSingleChoiceItems()&lt;/span&gt; is used to add the CharSequence declared before to the addded to the Alert Dialog.&lt;/li&gt;
&lt;li&gt;Finally we show the Alert Dialog using the &lt;span style=&quot;color: #3d85c6;&quot;&gt;show()&lt;/span&gt; member function.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/c3f59c3376f8d06606e8.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;2. Add the function to change the Paint Color&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Same as what we have done with stroke width , we are going to do with paint color.&lt;/li&gt;
&lt;li&gt;We create the Alert Dialog in same way as before.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;In&amp;nbsp;&lt;span style=&quot;color: #3d85c6;&quot;&gt;setSingleChoiceItems() &lt;/span&gt;we just use a switch-case construct to set the paint color accordingly.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/fcb732eb59c733ccd2b9.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;3. Change the onTouchEvent() method to store path and paint in Hash Map&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We use a private&lt;span style=&quot;color: #3d85c6;&quot;&gt; Map&lt;path aint=&quot;&quot;&gt; &lt;/path&gt;&lt;/span&gt;pathMap to store each path with its own paint settings.&lt;/li&gt;
&lt;li&gt;The values are put on the Hash Map on ACTION_UP, using the &lt;span style=&quot;color: #3d85c6;&quot;&gt;pathMap.put(key,value)&lt;/span&gt;.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/10e265202c7a7fd56f96.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;4. Change the onDraw() accordingly&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the onDraw() method just add for loop to loop through all the key-value pairs in our Hash Map.&lt;/li&gt;
&lt;li&gt;Draw all the paths using their own specific paints, both on the canvas and on the singleusecanvas (to store it on the bitmap as in &lt;a href=&quot;http://roadtodroid.blogspot.in/2014/11/sign-it-part-ii-saving-canvas-updating.html&quot;&gt;Part II&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/6e6e45cbcd34b7225dd1.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;5. Change the set_erase_on() method to clear all paths in Map&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Add the method to clear the hash map so as to clear all the paths stored.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/c4494c7c6d5cd301e44f.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h3 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #741b47;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;h3 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #7f6000;&quot;&gt;Sample Screenshots&lt;/span&gt;&lt;/h3&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU3QD0UTK3m34qlYg1WYo3A8ffWCBj9tq2dyPwMiJLL9-DvslxLMAjtlMPxFV9PL0jqwyulO_-vkA6fELzqsj5ftDfOh-Gs-S84Fh1kDqk-HdNB0WCYXGbtHKMZiXLQMdQM9h-MMpZvlk/s1600/DFG_2014-11-28-23-33-53.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgU3QD0UTK3m34qlYg1WYo3A8ffWCBj9tq2dyPwMiJLL9-DvslxLMAjtlMPxFV9PL0jqwyulO_-vkA6fELzqsj5ftDfOh-Gs-S84Fh1kDqk-HdNB0WCYXGbtHKMZiXLQMdQM9h-MMpZvlk/s1600/DFG_2014-11-28-23-33-53.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Stroke width selection&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoP3m00Vo96zlNGfvGkCW-b-Z18GHgP5G8joLLaubaeHE3PXFJemwJFgJLi8GBWxC4GYOM-mnEIiu09U_nzTY2y9Q3C6kD63n0EhlowWdxkBr76HsOTJIqT0RaLRwmkFayitDmqic3aA0/s1600/DFG_2014-11-28-23-33-58.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhoP3m00Vo96zlNGfvGkCW-b-Z18GHgP5G8joLLaubaeHE3PXFJemwJFgJLi8GBWxC4GYOM-mnEIiu09U_nzTY2y9Q3C6kD63n0EhlowWdxkBr76HsOTJIqT0RaLRwmkFayitDmqic3aA0/s1600/DFG_2014-11-28-23-33-58.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Color selection&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqabnsMJ_ycttR3r6JazsNt1qHo9fnUPhTf3kpBmq75xNsVQHqw9L05qTdFWHTmSN6gIpdF3QKnU2fuy0cpWGPhBw1mv-__hKSYXgRRVSflJW1U9vWAql1j-tNAjVBhM3JBsW9a4qYXmw/s1600/DFG_2014-11-28-23-34-17.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjqabnsMJ_ycttR3r6JazsNt1qHo9fnUPhTf3kpBmq75xNsVQHqw9L05qTdFWHTmSN6gIpdF3QKnU2fuy0cpWGPhBw1mv-__hKSYXgRRVSflJW1U9vWAql1j-tNAjVBhM3JBsW9a4qYXmw/s1600/DFG_2014-11-28-23-34-17.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOlhZLeZqkWX6ZLbt4NwdOcIe5HhbRUYpTQBvlL5SVAqt6cOMThbLifqRRmupV5aAJxP6BAEc2RiiNhaiomzrfAdd8g1PPffyo7uOeaFUcxEvvM1dyAKSYSpCL1jy_s-DIO9cqrjuwq3s/s1600/DFG_2014-11-28-23-34-05.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOlhZLeZqkWX6ZLbt4NwdOcIe5HhbRUYpTQBvlL5SVAqt6cOMThbLifqRRmupV5aAJxP6BAEc2RiiNhaiomzrfAdd8g1PPffyo7uOeaFUcxEvvM1dyAKSYSpCL1jy_s-DIO9cqrjuwq3s/s1600/DFG_2014-11-28-23-34-05.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglvGqTo3BRbK02L4jR13mwLg0UIadfz8C3TcwoZr4fr0MJNL1MaDj9ufFncm3611MU0sXDGDCoVM8mbhJ7vY_RoPjljRaDZLG72Lwhp87uI_VmetpA6klD1qQTVW2TKL29hzAHyptOWag/s1600/DFG_2014-11-28-23-34-32.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglvGqTo3BRbK02L4jR13mwLg0UIadfz8C3TcwoZr4fr0MJNL1MaDj9ufFncm3611MU0sXDGDCoVM8mbhJ7vY_RoPjljRaDZLG72Lwhp87uI_VmetpA6klD1qQTVW2TKL29hzAHyptOWag/s1600/DFG_2014-11-28-23-34-32.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #741b47;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: center;&quot;&gt;
&lt;span style=&quot;color: #741b47;&quot;&gt;&amp;nbsp;Download Source Code&lt;/span&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/48duvxuurha6y9n/AAD-5Olt9gp7Mnrcn2mp3R4la?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;download&quot; border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvoS_z5UZVuhUwuQI5S4inwVvbnqB-bh5mOjSCdnp1IswnC3k7C3Wbz0RnuXO2OkJmcgv9tHJr0GYIjbL4iH567OnBuH1B8eXCVlSmPVpZL7-25735w4kwIqfxTxbXi1jH0fJ6ZUSX7Ts/s1600/ic_cloud_download_black_48dp.png&quot; title=&quot;&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #741b47;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/11/signit-part-iii-alert-dialog-and-hashmap.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZKy68R_M7LW_509sLclKdfYRTs9l7Iu1Z1nUX42xRIfHw3wRgnhex6XIgWvCVVlnpwAOGFcKv87jNI0muRpLaB8YFIYwYWFxBrTdo62zZz_NdBfFV4NWN2LddxJusCMfBqcv7RKIwzNA/s72-c/sign+it+part+3.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-2427220632139496318</guid><pubDate>Tue, 04 Nov 2014 10:16:00 +0000</pubDate><atom:updated>2014-11-28T08:26:50.304-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Projects</category><category domain="http://www.blogger.com/atom/ns#">gallery</category><category domain="http://www.blogger.com/atom/ns#">MediaScannerConnection</category><category domain="http://www.blogger.com/atom/ns#">save canvas</category><category domain="http://www.blogger.com/atom/ns#">save to gallery</category><category domain="http://www.blogger.com/atom/ns#">Sign It! part 2</category><title>Sign It! Part II (Saving the Canvas &amp; Updating Gallery)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIFkzf5A9w9L-qyAlWOtP5By1YFVLbOQ5WmKMbC38cC8y9kpVijxpn_pmRqixcwFD4FFDdnkOzATdDq0Bsc7sz-Rvax1tVtOlsS_MlHuZsdUZXtJy_FIpryZaTjEcbRTwn4lOLf7d4PrQ/s1600/sign+it+part+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIFkzf5A9w9L-qyAlWOtP5By1YFVLbOQ5WmKMbC38cC8y9kpVijxpn_pmRqixcwFD4FFDdnkOzATdDq0Bsc7sz-Rvax1tVtOlsS_MlHuZsdUZXtJy_FIpryZaTjEcbRTwn4lOLf7d4PrQ/s1600/sign+it+part+2.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Welcome to the part 2 of the Sign It! app series on roadtodroid. In this post we explore the method to save our drawing from the canvas to a bitmap image &amp;amp; also to store that image onto the system storage.&lt;br /&gt;
For this part I will use the app made till the previous post and build onto it only. So I recommend your to go through that one first.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;1. Update the onDraw() method to create Bitmap for the canvas&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the onDraw() method , previously we only drew to the view using&amp;nbsp;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;canvas&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot; style=&quot;background-color: white; box-sizing: border-box; color: teal; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;drawPath&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;paint&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;);&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;We now &amp;nbsp;create a new temporary canvas and call it&amp;nbsp;&lt;span style=&quot;color: #3d85c6;&quot;&gt;singleuseCanvas&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;Also we create a global Bitmap called &lt;span style=&quot;color: #3d85c6;&quot;&gt;myBitmap&lt;/span&gt; to store each update to &lt;span style=&quot;color: #3d85c6;&quot;&gt;singleuseCanvas&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;We first set&amp;nbsp;&lt;span style=&quot;color: #3d85c6;&quot;&gt;myBitmap&lt;/span&gt;&amp;nbsp;to singleuseCanvas using&amp;nbsp;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;singleuseCanvas&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot; style=&quot;background-color: white; box-sizing: border-box; color: teal; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;setBitmap&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;myBitmap&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;).&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;We then draw to the new canvas using&amp;nbsp;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;singleuseCanvas&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot; style=&quot;background-color: white; box-sizing: border-box; color: teal; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;drawPath&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;paint&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;).&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;And finally we draw to the Bitmap using&amp;nbsp;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;singleuseCanvas&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot; style=&quot;background-color: white; box-sizing: border-box; color: teal; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;drawBitmap&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;myBitmap&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;background-color: white; box-sizing: border-box; color: #945277; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;mi&quot; style=&quot;background-color: white; box-sizing: border-box; color: #945277; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;paint&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;). &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/019a165e7b02b4c402e2.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;2. Save the Bitmap when Save on Action Bar is pressed&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul&gt;
&lt;li&gt;When the save button is pressed we call the function saveMyBitmap(); in the CanvasView.&lt;/li&gt;
&lt;li&gt;Here we first create an empty &lt;span style=&quot;color: #3d85c6;&quot;&gt;FileOutputStream&lt;/span&gt; (For more visit : &lt;a href=&quot;http://developer.android.com/reference/java/io/FileOutputStream.html&quot;&gt;http://developer.android.com/reference/java/io/FileOutputStream.html&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;Now we get the root path for the External SD card using&amp;nbsp;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;Environment&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot; style=&quot;background-color: white; box-sizing: border-box; color: teal; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;getExternalStorageDirectory&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;().&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;After this we create a new File object giving its constructor the path of the directory we want our images to be stored on. This is done by appending root string to &quot;Sign It&quot; folder(You can give any name). The &lt;span style=&quot;color: #3d85c6;&quot;&gt;File.separator&lt;/span&gt; is the devices&#39; default &amp;amp; specific file separator .&lt;/li&gt;
&lt;li&gt;Then we just create the string containing the name we want to give our file (I have used the systems current date &amp;amp; &amp;nbsp;time), create another file containing root and file name, give that to the FileOutputStream.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;We use compress method on myBitmap to compress and put it on the output stream.&lt;/li&gt;
&lt;li&gt;Finally we flush and close the stream.&lt;/li&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/50b231068c882a648be4.js&quot;&gt;&lt;/script&gt;
&lt;li&gt;Also remember to add the following line to the manifest file:&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/1d25ff5829efc8454fc2.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;3. Update Gallery&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Now the next thing is to notify the gallery to update its data when we save a new image to our phone storage. To accomplish this we &lt;span style=&quot;color: #3d85c6;&quot;&gt;&lt;a href=&quot;http://developer.android.com/reference/android/media/MediaScannerConnection.html&quot;&gt;MediaScannerConnection&lt;/a&gt;&lt;/span&gt; class.&lt;/li&gt;
&lt;li&gt;The context used in the function is the context of our MainActivity which we will pass later in the MainActivity.&lt;/li&gt;
&lt;li&gt;The code is quite straight forward.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/953dbd546bd5f2112ace.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;4. Modify the MainActivity&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the main activity just add the corresponding function calls in the&amp;nbsp;&lt;span style=&quot;background-color: white; color: #945277; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;onOptionsItemSelected&lt;/span&gt;.&lt;/li&gt;
&lt;li&gt;Also here we add a new method called &amp;nbsp;&lt;span class=&quot;nf&quot; style=&quot;background-color: white; box-sizing: border-box; color: #945277; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;opengallery&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;() &lt;/span&gt;to open gallery from our app only. The ACTION_VIEW specifies that some data is to be shown to user of which the Uri we have parsed. Also we add a flag to the intent&amp;nbsp;&lt;span class=&quot;n&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;o&quot; style=&quot;background-color: white; box-sizing: border-box; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; font-weight: bold; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot; style=&quot;background-color: white; box-sizing: border-box; color: teal; font-family: Consolas, &#39;Liberation Mono&#39;, Menlo, Courier, monospace; font-size: 12px; line-height: 16.7999992370605px; white-space: pre;&quot;&gt;FLAG_ACTIVITY_NO_HISTORY &lt;/span&gt;, which restricts gallery to be kept in stack.&lt;/li&gt;
&lt;li&gt;And now just run the project.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/ebfbb4b4dc68394c7ce8.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;PREVIEW:&lt;/span&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF_-uvMgAPrYtTYRcrZgi9cvHvn0g8vujNZl0ukPJ1INUAHchWf9ViiOXs4yRZAP99Ba7RYxkgAormpuXVlsWOnvTszGbjhuYC0jPyf6tUHgZPa5BMYeg_RROGrQnV2HSe9h4EridVVDg/s1600/DFG_2014-11-04-15-24-53.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhF_-uvMgAPrYtTYRcrZgi9cvHvn0g8vujNZl0ukPJ1INUAHchWf9ViiOXs4yRZAP99Ba7RYxkgAormpuXVlsWOnvTszGbjhuYC0jPyf6tUHgZPa5BMYeg_RROGrQnV2HSe9h4EridVVDg/s1600/DFG_2014-11-04-15-24-53.png&quot; height=&quot;400&quot; width=&quot;237&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYaVR29AvZisj2hp3cJccm-w_616g5XOh2AJBiqCehyphenhyphenRoK0XxXlzqBCZ__z-91bCG6KBepf8ayNFVaR6q7bXyMPF3-btOzJZ9HsHnevBweGlD-OdqshmZ8JF_Mt6ZkoYE07SQO6-nzV9c/s1600/DFG_2014-11-04-15-24-05.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYaVR29AvZisj2hp3cJccm-w_616g5XOh2AJBiqCehyphenhyphenRoK0XxXlzqBCZ__z-91bCG6KBepf8ayNFVaR6q7bXyMPF3-btOzJZ9HsHnevBweGlD-OdqshmZ8JF_Mt6ZkoYE07SQO6-nzV9c/s1600/DFG_2014-11-04-15-24-05.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Scribble down&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0sZCap4UXkMmdSVE19TW1cXU98wNkDpsLSc_4J0AbyYFwb346aWPLLypsb-6eEUjy71kcErXyKvdLzlC3Ssmp_Bi9zFdIAxKwmQ_yMHaqgea52yLqr1tObFP7BrzOO9dmd5yYtsclyRY/s1600/DFG_2014-11-04-15-24-09.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0sZCap4UXkMmdSVE19TW1cXU98wNkDpsLSc_4J0AbyYFwb346aWPLLypsb-6eEUjy71kcErXyKvdLzlC3Ssmp_Bi9zFdIAxKwmQ_yMHaqgea52yLqr1tObFP7BrzOO9dmd5yYtsclyRY/s1600/DFG_2014-11-04-15-24-09.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Click Save icon&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgIM6YACHZbpqk6bYmcxoeTuQJ9HFz89kFKTFLkw4X2zc_Ncj5XaXf9pfpxb3LWIkV9fnq4PRlwOadx_5T_-44P1EyK4EBqWBORZmyBx2bEJgUzvdhCNrmXMz7rKBem5_6ymcOqlFoMpA/s1600/DFG_2014-11-04-15-24-27.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgIM6YACHZbpqk6bYmcxoeTuQJ9HFz89kFKTFLkw4X2zc_Ncj5XaXf9pfpxb3LWIkV9fnq4PRlwOadx_5T_-44P1EyK4EBqWBORZmyBx2bEJgUzvdhCNrmXMz7rKBem5_6ymcOqlFoMpA/s1600/DFG_2014-11-04-15-24-27.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Images stored in gallery&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQuLNzwK5bFolaBZJ_qI3oVhh5klAXRhVJH4PF1Qo-aGQZex3wAhybhaWSmAh8NekOrZNae-GsKx6odwjJvz3hcV3YWjaVDPIAMiH_XMVYDsxvCCwvvP1L-DXdx5IWqh8WnQDWPW1Tj9c/s1600/DFG_2014-11-04-15-30-25.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQuLNzwK5bFolaBZJ_qI3oVhh5klAXRhVJH4PF1Qo-aGQZex3wAhybhaWSmAh8NekOrZNae-GsKx6odwjJvz3hcV3YWjaVDPIAMiH_XMVYDsxvCCwvvP1L-DXdx5IWqh8WnQDWPW1Tj9c/s1600/DFG_2014-11-04-15-30-25.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Voila!!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Download Code:&lt;/span&gt;&lt;/h2&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://www.dropbox.com/sh/55msxvbggr18jhd/AAD1MFYxVEUelzDyT0qFHHSca?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhRxIzAcLJVmGJz1myBbuJyZOH1GKuaoS8ywnGQLIjxJxLaQCdOZMuf-dRHMwrIdWYInJM6HNQ2R-mOqpLIhm-fyBncjQuxO7MJcaXraZ4t7dGf3S7BOdI7FNRqfjiCEJUJJMW7Uj_ZP08/s1600/ic_cloud_download_black_48dp.png&quot;  /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;CLICK THE ICON&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;!-- Blogger automated replacement: &quot;https://images-blogger-opensocial.googleusercontent.com/gadgets/proxy?url=http%3A%2F%2F4.bp.blogspot.com%2F-YlR78bcNavA%2FVFii0W_nDII%2FAAAAAAAAAZE%2FvBtzd0-CfdU%2Fs1600%2FDFG_2014-11-04-15-24-05.png&amp;amp;container=blogger&amp;amp;gadget=a&amp;amp;rewriteMime=image%2F*&quot; with &quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYaVR29AvZisj2hp3cJccm-w_616g5XOh2AJBiqCehyphenhyphenRoK0XxXlzqBCZ__z-91bCG6KBepf8ayNFVaR6q7bXyMPF3-btOzJZ9HsHnevBweGlD-OdqshmZ8JF_Mt6ZkoYE07SQO6-nzV9c/s1600/DFG_2014-11-04-15-24-05.png&quot; --&gt;</description><link>http://roadtodroid.blogspot.com/2014/11/sign-it-part-ii-saving-canvas-updating.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgIFkzf5A9w9L-qyAlWOtP5By1YFVLbOQ5WmKMbC38cC8y9kpVijxpn_pmRqixcwFD4FFDdnkOzATdDq0Bsc7sz-Rvax1tVtOlsS_MlHuZsdUZXtJy_FIpryZaTjEcbRTwn4lOLf7d4PrQ/s72-c/sign+it+part+2.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-559033320878301661</guid><pubDate>Mon, 13 Oct 2014 18:49:00 +0000</pubDate><atom:updated>2014-10-13T11:52:25.205-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Compile statement</category><category domain="http://www.blogger.com/atom/ns#">Query Optimization</category><category domain="http://www.blogger.com/atom/ns#">String.format</category><category domain="http://www.blogger.com/atom/ns#">StringBuilder</category><category domain="http://www.blogger.com/atom/ns#">Tips &amp; Tricks</category><category domain="http://www.blogger.com/atom/ns#">Transactions</category><title>Query optimization &amp; Transactions</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCzy5rhq1TAHZsbPjUCeDglvtDxuYUG_XqQVfA1OC_sQ1IuG-_Vn0Z7tk0EvgEMz7kLyST2T0eWkoEMNpLk-gmYeWnPiTIsv9Zas-XBcaQiPoOXgwifgqc9KJEQoVq6faRzAYS-Yu9ZIY/s1600/new-prof.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCzy5rhq1TAHZsbPjUCeDglvtDxuYUG_XqQVfA1OC_sQ1IuG-_Vn0Z7tk0EvgEMz7kLyST2T0eWkoEMNpLk-gmYeWnPiTIsv9Zas-XBcaQiPoOXgwifgqc9KJEQoVq6faRzAYS-Yu9ZIY/s1600/new-prof.png&quot; height=&quot;275&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
This post explores some of the concepts of query optimization &amp;amp; transaction management for Android apps. Most of the applications won&#39;t be using so much of the SQLite features but it&#39;s always good to know about possible optimizations when you deal with databases. I referenced the book Pro Android Apps Performance Optimization by published Apress.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;1. Basic SQLite Statements&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
The basic SQLite statements are simple strings like-&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;CREATE TABLE phone(devicename TEXT, company TEXT)&lt;/li&gt;
&lt;li&gt;INSERT INTO phone VALUES(&#39;M8&#39;,&#39;HTC&#39;)&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
The above statements are just simple strings &amp;amp; they have to be interpreted,or compiled before they can be executed. The compilation of these statements is down internally when we call the &lt;sqlitedatabase&gt;.&lt;span style=&quot;color: #3d85c6;&quot;&gt;execSQL(&lt;/span&gt;&lt;statement&gt;&lt;span style=&quot;color: #3d85c6;&quot;&gt;)&lt;/span&gt;.&lt;/statement&gt;&lt;/sqlitedatabase&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
The following code demonstrates how these statements are executed.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/db8aa06ba25a169b08dc.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
The problems with the above implementation is that SQLite statements takes some quite some time to execute.&amp;nbsp;In addition to the&amp;nbsp;compilation, the statements themselves may need to be created. String is also&amp;nbsp;&lt;span style=&quot;color: #3d85c6;&quot;&gt;immutable&lt;/span&gt;(String is immutable means that you cannot change the object itself, but you can change the reference ) ,which poses performance issues here.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;2. The INSERT Statement String&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
INSERT is the most used statement in any SQLite database as you are bound to insert several entries into the database.A basic implementation of inserting several values into the database is shown below.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/0049809e8a49042286f2.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;div&gt;
The problem with the above implementation is that for every insert statement, a String would be created and execSQL would be called.This prcedure takes a lot of time and memory.&lt;/div&gt;
&lt;div&gt;
One solution for this problem is to avoid using the&amp;nbsp;+ operator for String concatenation &amp;amp; instead use a StringBuilder object or calling String.format.The two new methods are shown below&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/1f235cf804decd1fbeac.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;3. The Compile Statement&lt;/span&gt;&amp;nbsp;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
Now since we have addressed the issue of using &amp;amp; interpreting the sting statements, the next issue is of execSQL method.The execSQL does the actual compilation(parsing) of the statement.In the above examples the execSQL statement is called for every insertion to the database. All this can be avoided by only compiling the statement once &amp;amp; binding later.This is depicted below.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/2d28679f1dc4a3f76fbe.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;4. Using ContentValues&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
As we avoided the use of execSQL staement above, the same can be achieved using a ContentValues object. Its not better than the Compile statement method. but either way its an elegant method of getting things done.&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/1419cfba7e582acf61ae.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;5. Transactions&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
Transactions are automatically created when we perform any read/write from the the database. But creating explicit transaction can improve the performance tremendously.The implementation of &amp;nbsp;explicit transaction on compile statement is depicted below.&lt;/div&gt;
&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/1cee02aec2eb6a17a025.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/10/query-optimization-transactions.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCzy5rhq1TAHZsbPjUCeDglvtDxuYUG_XqQVfA1OC_sQ1IuG-_Vn0Z7tk0EvgEMz7kLyST2T0eWkoEMNpLk-gmYeWnPiTIsv9Zas-XBcaQiPoOXgwifgqc9KJEQoVq6faRzAYS-Yu9ZIY/s72-c/new-prof.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-1302204856466705179</guid><pubDate>Fri, 10 Oct 2014 16:38:00 +0000</pubDate><atom:updated>2014-11-28T08:27:00.021-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Projects</category><category domain="http://www.blogger.com/atom/ns#">Canvas</category><category domain="http://www.blogger.com/atom/ns#">Custom View</category><category domain="http://www.blogger.com/atom/ns#">Erase canvas</category><category domain="http://www.blogger.com/atom/ns#">invalidate()</category><category domain="http://www.blogger.com/atom/ns#">Menu inflator</category><category domain="http://www.blogger.com/atom/ns#">MenuInflator</category><category domain="http://www.blogger.com/atom/ns#">MotionEvent</category><category domain="http://www.blogger.com/atom/ns#">Paint</category><category domain="http://www.blogger.com/atom/ns#">Path</category><category domain="http://www.blogger.com/atom/ns#">Pen</category><title>Sign It ! Part I (Drawing on the Canvas)</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirrKZ2_KIVJvuB6eaRwWSD4RxJuqPxaGN_LM-CX3O2NcCH4xEjpRGxnAeemRsRU8QGRLWAMM8Re4ZZ-UPL3REaROIbm7ANyUnZjjE1ozAsZtBmeeQw7Jy_ao8jaiSA8KTx-ljPARyDYGk/s1600/signit+part+1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirrKZ2_KIVJvuB6eaRwWSD4RxJuqPxaGN_LM-CX3O2NcCH4xEjpRGxnAeemRsRU8QGRLWAMM8Re4ZZ-UPL3REaROIbm7ANyUnZjjE1ozAsZtBmeeQw7Jy_ao8jaiSA8KTx-ljPARyDYGk/s1600/signit+part+1.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Hello &amp;amp; welcome to the very first Android Project of roadtodroid. In this section we explore various new functionality under the hood of Android &amp;amp; learn how to use all of them to make our app work effortlessly.&lt;br /&gt;
So let me first tell you about the things we are gonna explore with Sign It!&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;How to draw on canvas in Android?&lt;/li&gt;
&lt;li&gt;How to clear a canvas?&lt;/li&gt;
&lt;li&gt;How to use action bar icons to inflate menus?&lt;/li&gt;
&lt;li&gt;How to save the contents of the canvas to the phone memory?&lt;/li&gt;
&lt;li&gt;How to change the pen size and color using action bar icon selections? and many more....&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
This whole app will be demonstrated in several parts, so be patient &amp;amp; go through everything thoroughly.This part demonstrates how to give your app the functionality of a canvas to draw upon. Also how to erase the whole canvas will also be discussed. All this plus adding icons to action bar and using them is also demonstrated. So get ready for this action packed ride to program Android apps &amp;amp; hope you will enjoy it. Feel free to post any constructive comments.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;1. Create a new Android Application Project&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;li&gt;In the dialog &amp;nbsp;displayed, enter a name for your app(Sign It!).&lt;/li&gt;
&lt;li&gt;Select a target SDK version to make the app targeted for a particular Android distribution.&lt;/li&gt;
&lt;li&gt;Also select a Minimum Required SDK to make the app backward compatible as far back as you want.&lt;/li&gt;
&lt;li&gt;You may also select a Theme for the app if you like.&lt;/li&gt;
&lt;li&gt;Do not change anything if you don&#39;t want to as it is pre-selected accordingly. Then click Next.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnz8IOv2rEO3EGDAWN72Gj23QB3sCKlKMQXipF-CYof2f4mKTphuyEnDlc6hc1qhgtUIYpi4QSr_-btGPZWllWgae_faAaRbmLIIE92o6zr5Xik5QPsPNQ2HLomgZzGiHqopVLEZSyX0M/s1600/sign+it+name.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnz8IOv2rEO3EGDAWN72Gj23QB3sCKlKMQXipF-CYof2f4mKTphuyEnDlc6hc1qhgtUIYpi4QSr_-btGPZWllWgae_faAaRbmLIIE92o6zr5Xik5QPsPNQ2HLomgZzGiHqopVLEZSyX0M/s1600/sign+it+name.PNG&quot; height=&quot;342&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Give a name to the app&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the next dialog just click next or if you want your project to be save elsewhere(other than the current work space ) choose that from the option provided.Click next.&lt;/li&gt;
&lt;li&gt;Next dialog allows you to select a custom icon for your app. Select one if you like, fiddle with background color and other options and click next.&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoGZ2y7WURc9UiOuMr5qMz6wecx2w893PdNslTACai3eyxf1XK5L_foquMdCCWiEJbl27O6lEU96s31bNFnMr7Hox5KSnnAaE2_b-i0k_WKliRUq58p4FEdtUzEJ1F_ylsm4IKGtEOViw/s1600/icon_page.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjoGZ2y7WURc9UiOuMr5qMz6wecx2w893PdNslTACai3eyxf1XK5L_foquMdCCWiEJbl27O6lEU96s31bNFnMr7Hox5KSnnAaE2_b-i0k_WKliRUq58p4FEdtUzEJ1F_ylsm4IKGtEOViw/s1600/icon_page.PNG&quot; height=&quot;356&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Select icon&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the next dialog box select Empty Activity and click next. Similarly click next in the last dialog box.&lt;/li&gt;
&lt;li&gt;This would create a project file in the Package Explorer of Eclipse.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;2. MainActivity.java&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the MainActivity.java file copy the code shown below to your activity and change the package name to that of your&#39;s if any error is shown.&lt;/li&gt;
&lt;li&gt;For now just copy the code &amp;amp; go to the end of this post in the Code Explained section to discuss more on the code.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/9c444189629a447b0489.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;3. Create a new Class for the Custom View implementation&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to the package in your project, right-click on it and select New&amp;gt; Class.&lt;/li&gt;
&lt;li&gt;Give a name for the class(I have used CanvasView.java), &amp;amp; click Finish.&lt;/li&gt;
&lt;li&gt;Once the class is created , open it &amp;amp; copy the code below to it.&lt;/li&gt;
&lt;li&gt;For more in-depth discussion go to the end of this post.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/7fce95ba8514bec60869.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;4. Create a menu to use in Action Bar&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the res folder under your project, create a new folder by right clicking on res and selecting New Folder.&lt;/li&gt;
&lt;li&gt;Change the name of the folder to &#39;menu&#39;.&lt;/li&gt;
&lt;li&gt;Now right click on this menu folder and select a new Android XML file from there. Name it my_menu.xml (or anything).&lt;/li&gt;
&lt;li&gt;Now to this xml file copy the code shown below to create some of the menu elements &amp;amp; icons.&lt;/li&gt;
&lt;li&gt;I have also added two pngs to the res/drawable-hdpi folder as shown below. The icons are downloaded from&amp;nbsp;&lt;a href=&quot;http://www.iconarchive.com/&quot;&gt;&lt;span style=&quot;background-color: white; font-family: arial, sans-serif; font-size: 13px; line-height: 16px; white-space: nowrap;&quot;&gt;www.&lt;/span&gt;&lt;b style=&quot;background-color: white; font-family: arial, sans-serif; font-size: 13px; line-height: 16px; white-space: nowrap;&quot;&gt;icon&lt;/b&gt;&lt;span style=&quot;background-color: white; font-family: arial, sans-serif; font-size: 13px; line-height: 16px; white-space: nowrap;&quot;&gt;archive.com&amp;nbsp;&lt;/span&gt;&lt;/a&gt;&amp;nbsp;&amp;amp; can be downloaded from the Download Code section at the end.&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmWnf5FRUc2xYuahx_F-FZYiD4nVmHpkjv2A_mTkRMevgkor7il2BBDO-Njz_MoQDlzDBVm8RILng7FEJ3mvuzmnHoIvDU3m13A2U8DIOVsx594dCkDlUGyOfNx-k22iu135YeEqenXkI/s1600/menufolder.PNG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmWnf5FRUc2xYuahx_F-FZYiD4nVmHpkjv2A_mTkRMevgkor7il2BBDO-Njz_MoQDlzDBVm8RILng7FEJ3mvuzmnHoIvDU3m13A2U8DIOVsx594dCkDlUGyOfNx-k22iu135YeEqenXkI/s1600/menufolder.PNG&quot; height=&quot;400&quot; width=&quot;160&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;menu folder in res&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfcZg11tE5_FXp4tOkO6wllv177rq4_rQHXzqPswYIx0ad9rK5E6BS7XsbZxvUVPDko2fr1gu6ujnxIjra19visngeF4KKEHrEdYl6r6hhyphenhyphen8O4vNzElRonNAomEUZ2rD3_9Yl4uq9-TlY/s1600/drawable.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhfcZg11tE5_FXp4tOkO6wllv177rq4_rQHXzqPswYIx0ad9rK5E6BS7XsbZxvUVPDko2fr1gu6ujnxIjra19visngeF4KKEHrEdYl6r6hhyphenhyphen8O4vNzElRonNAomEUZ2rD3_9Yl4uq9-TlY/s1600/drawable.PNG&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;icons in the drawable-hdpi folder&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/939944dbbefa26b56ce5.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;5. Everything is ready&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;You are now done with the coding part. The only thing left is to test the app either on a real physical device or on an AVD.&lt;/li&gt;
&lt;li&gt;To setup an AVD see my previous post.&lt;/li&gt;
&lt;li&gt;To run on a physical device connect the device through USB. Make sure the developer options are enabled &amp;amp; the USB Debugging is checked.&lt;/li&gt;
&lt;li&gt;Also make sure that the drivers for your device are installed properly. To do this I used the software named moborobo .You can get is from&amp;nbsp;&lt;a href=&quot;http://www.moborobo/&quot;&gt;&lt;span style=&quot;background-color: white; font-family: arial, sans-serif; font-size: 13px; line-height: 16px; white-space: nowrap;&quot;&gt;www.&lt;/span&gt;&lt;b style=&quot;background-color: white; font-family: arial, sans-serif; font-size: 13px; line-height: 16px; white-space: nowrap;&quot;&gt;moborobo&lt;/b&gt;&lt;/a&gt;&lt;span style=&quot;background-color: white; font-family: arial, sans-serif; font-size: 13px; line-height: 16px; white-space: nowrap;&quot;&gt;&lt;a href=&quot;http://.com/&quot;&gt;.com&lt;/a&gt;.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;After all this just press CTRL + F11 in Eclipse &amp;amp; you are done.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7JMIzwzH2QLEcThyphenhyphendG5QCiiem6rDoHHuMnMGc98H2sMaN39kbdxltkUj2183ZxcXHBzvq5pWnAIodUTxs5wP7ZsSWR2ISt8hhfcAwoSQ7I2ltMOd3JJwRIPRX4nURe1PBofsS1WgQNJY/s1600/DFG_2014-10-08-18-45-47.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7JMIzwzH2QLEcThyphenhyphendG5QCiiem6rDoHHuMnMGc98H2sMaN39kbdxltkUj2183ZxcXHBzvq5pWnAIodUTxs5wP7ZsSWR2ISt8hhfcAwoSQ7I2ltMOd3JJwRIPRX4nURe1PBofsS1WgQNJY/s1600/DFG_2014-10-08-18-45-47.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;App launch view&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2ctUvPUBtBcSNtL2Zj-x3gAQYHFod-kmPAYuLzuwWn-eBt4EJnbCRcFrb4fSb_vrjTy8MT95Z5BryeYfU-m_dOYURYEpP0nJnI64V6jWm74lnV_r0Iim7wqVPi25DdT9hcnnwi_cWWnc/s1600/DFG_2014-10-08-18-45-51.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj2ctUvPUBtBcSNtL2Zj-x3gAQYHFod-kmPAYuLzuwWn-eBt4EJnbCRcFrb4fSb_vrjTy8MT95Z5BryeYfU-m_dOYURYEpP0nJnI64V6jWm74lnV_r0Iim7wqVPi25DdT9hcnnwi_cWWnc/s1600/DFG_2014-10-08-18-45-51.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Scribble around!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgI1CUWtlm33mFX8Ti_2hW2Tkwdo_ucANQiz36KkXklXzfP0pC4J6r7AJOfiixVUf7qHpuFTZLW0dNw_0ZGbXtF88uyolWBNT-ko4A05Kmhs3Qw8COiX4FY649RPeFsmU8cXsbWgGBMnc/s1600/DFG_2014-10-08-18-45-55.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgI1CUWtlm33mFX8Ti_2hW2Tkwdo_ucANQiz36KkXklXzfP0pC4J6r7AJOfiixVUf7qHpuFTZLW0dNw_0ZGbXtF88uyolWBNT-ko4A05Kmhs3Qw8COiX4FY649RPeFsmU8cXsbWgGBMnc/s1600/DFG_2014-10-08-18-45-55.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Erase anytime&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM42FetSkHLNj0DobskISb20DXDEh0Z4MfmIk-MGM82qNkKt55hB3dzQu6fbtynRntXr7_zsJWDctF3gyw3c5Ax_PjZEoPbKWG1owMkYunox9-jD71Vr06opK1oI7P_YbSpGFluKO0j5E/s1600/DFG_2014-10-08-18-46-38.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgM42FetSkHLNj0DobskISb20DXDEh0Z4MfmIk-MGM82qNkKt55hB3dzQu6fbtynRntXr7_zsJWDctF3gyw3c5Ax_PjZEoPbKWG1owMkYunox9-jD71Vr06opK1oI7P_YbSpGFluKO0j5E/s1600/DFG_2014-10-08-18-46-38.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;And many more to come!&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Code Explained&lt;/span&gt;&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #3d85c6;&quot;&gt;CanvasView.java&lt;/span&gt;&lt;/h3&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;This is a class which extends the View class of Android which means that it can be used for managing drawings on the main UI thread &amp;amp; also handle user interactions. For more on this check out&amp;nbsp;&lt;a href=&quot;http://developer.android.com/reference/android/view/View.html&quot;&gt;http://developer.android.com/reference/android/view/View.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Firstly we create three global variables paint,path &amp;amp; a Boolean flag.&amp;nbsp;The &lt;span style=&quot;color: #6aa84f;&quot;&gt;Paint&lt;/span&gt; class holds the style and color information about how to draw geometries, text and bitmaps.The &lt;span style=&quot;color: #6aa84f;&quot;&gt;Path&lt;/span&gt; class encapsulates compound (multiple contour) geometric paths consisting of straight line segments, quadratic curves, and cubic curves.&lt;/li&gt;
&lt;li&gt;Don&#39;t get confused just stay focused here.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The class CanvasView has a &lt;span style=&quot;color: #6aa84f;&quot;&gt;constructor&lt;/span&gt; with the same name which initializes the paint object using the member functions of the Paint class.The functions are quite obvious to understand from their name only. For any kind of suggestions just press Ctrl + Space in Eclipse.&lt;/li&gt;
&lt;li&gt;Next in the &lt;span style=&quot;color: #6aa84f;&quot;&gt;onDraw()&lt;/span&gt; method we just draw the path to which we will add points later.The path is drawn on the canvas using &lt;span style=&quot;color: #6aa84f;&quot;&gt;drawPath(&lt;path&gt;,&lt;paint&gt;)&lt;/paint&gt;&lt;/path&gt;&lt;/span&gt; method on canvas object.&lt;/li&gt;
&lt;li&gt;In the next method i.e. onTouchEvent() which is used to handle user interactions, we add to the path the points the user touches or moves to.This is pretty simple:&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a.) We get the current touch position using the getX() &amp;amp; getY() methods on the event object.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; b.) Then we use a switch on the the type of event or interaction the user has performed.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;It can be either the touching of the screen or moving around on it. The names are fairly obvious,&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; c.) On&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;MotionEvent.ACTION_DOWN&lt;/span&gt; we simply add X &amp;amp; Y to the path using &lt;span style=&quot;color: #6aa84f;&quot;&gt;moveTo(X,Y) &lt;/span&gt;on path object.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; d.) On&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;MotionEvent.ACTION_MOVE&lt;/span&gt; we draw a line to X,Y using &lt;span style=&quot;color: #6aa84f;&quot;&gt;lineTo(X,Y)&lt;/span&gt;.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; e.)Finally to force a view to draw, we call invalidate().&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #3d85c6;&quot;&gt;my_menu.xml&lt;/span&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;This is the xml file used to tell Android about the content to be drawn in the Action Bar.&lt;/li&gt;
&lt;li&gt;The xml contains four item tags, all having different id &amp;amp; title.&lt;/li&gt;
&lt;li&gt;An icon is provided using the android:icon property.&lt;/li&gt;
&lt;li&gt;The&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;android:showAsAction&lt;/span&gt;=&quot;ifRoom&quot;&amp;nbsp;or&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;android:showAsAction&lt;/span&gt;=&quot;always&quot; are used to make items hidden if no room is available or to show them anyway.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #3d85c6;&quot;&gt;MainActivity.java&lt;/span&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The main activity in the &lt;span style=&quot;color: #6aa84f;&quot;&gt;onCreate()&lt;/span&gt; method initializes the global CanvasView object and used it in the setContentView() to make it the main UI view of the application.&lt;/li&gt;
&lt;li&gt;Then in the onCreateOptionsMenu() method we create a &lt;span style=&quot;color: #6aa84f;&quot;&gt;MenuInflator&lt;/span&gt; object and we inflate our menu using its &lt;span style=&quot;color: #6aa84f;&quot;&gt;inflate()&lt;/span&gt; method.&lt;/li&gt;
&lt;li&gt;Lastly in the&amp;nbsp;onOptionsItemSelected() method we use a switch on the item id we provided in the my_menu.xml &amp;amp; perform required operations accordingly.&lt;/li&gt;
&lt;li&gt;The rest of the code is pretty straight forward &amp;amp; can be done in multiple ways.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Download Code&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/9l9g6lagwf9ticy/AACTDlI6qGfNNY0tcrVtt8C1a?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheL8pHZo2Th4Rb5IvjzHdFpj5S2Pqs2G_X6vYfxF62qZCCvunLVOh7ElPXLRw9-PPBNh9oOM7m1hJ70UedrNbl6T2SzyujjetWhhAvs2wHj2nl-AAMduHpWptTnYAm1d3npQCr7S9v2iI/s1600/unnamed.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/10/sign-it-part-i.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirrKZ2_KIVJvuB6eaRwWSD4RxJuqPxaGN_LM-CX3O2NcCH4xEjpRGxnAeemRsRU8QGRLWAMM8Re4ZZ-UPL3REaROIbm7ANyUnZjjE1ozAsZtBmeeQw7Jy_ao8jaiSA8KTx-ljPARyDYGk/s72-c/signit+part+1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-3354374101191383442</guid><pubDate>Wed, 01 Oct 2014 16:14:00 +0000</pubDate><atom:updated>2014-10-02T02:38:27.164-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Basics</category><category domain="http://www.blogger.com/atom/ns#">Android Database Part II</category><category domain="http://www.blogger.com/atom/ns#">Form</category><category domain="http://www.blogger.com/atom/ns#">Form Verification</category><category domain="http://www.blogger.com/atom/ns#">Intent extras</category><category domain="http://www.blogger.com/atom/ns#">Remove from database</category><category domain="http://www.blogger.com/atom/ns#">Reuse layout</category><category domain="http://www.blogger.com/atom/ns#">Reuse Views</category><category domain="http://www.blogger.com/atom/ns#">Update database</category><title>Android Database Part II</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4nPt9d5d5S81chOtCcM58Ah3KWHdVA7DKnGhPVSbm-r4aEBcMNt5MXKl6Lqh0m-BfzApycGpWdSn841C9S2kTII7XVlYF15Pp5RvhoTUfKs5YgQ7_-tewRA3ciWc8TP1ZSDJz-8lclSU/s1600/android+database+part+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4nPt9d5d5S81chOtCcM58Ah3KWHdVA7DKnGhPVSbm-r4aEBcMNt5MXKl6Lqh0m-BfzApycGpWdSn841C9S2kTII7XVlYF15Pp5RvhoTUfKs5YgQ7_-tewRA3ciWc8TP1ZSDJz-8lclSU/s1600/android+database+part+2.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Hello World! Welcome back to Android Database series to learn some basic database features of the SQLite in Android. This post builds on the concepts and classes made in the previous part , i.e, &lt;a href=&quot;http://roadtodroid.blogspot.in/2014/09/android-database-part-i.html&quot;&gt;Android Database Part I&lt;/a&gt;. So I would recommend you to go through it before reading this one.&lt;br /&gt;
&lt;br /&gt;
Now I would assume that you have read the previous post on database &amp;amp; already have the classes and activities implemented there, cause we are gonna add to them in this part. So let&#39;s begin:&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;1. Changes in MainActivity.java&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;There are as such no big changes in this main activity. I only removed all the code from the onClickListner of sign in button , and created a new function to increase readability.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/7fc05e4c7534f2e19a2a.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;2. Changes in My_DbHelper.java class&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;We created two new methods here in this class , one to delete selected users from the database , &amp;amp; other to update any selected user info from the list.&lt;/li&gt;
&lt;li&gt;In the delete-user() method we just get an object of SQLiteDatabase for our class in the writable mode using getWritableDatabase(). Then we pass the id value passed to the method, to the &lt;dbobject&gt;.delete() method.&lt;/dbobject&gt;&lt;/li&gt;
&lt;li&gt;In the same way we create update_user() method and create a ContentValues object using the parameters passed. The &lt;dbobject&gt;.update() method is then used.&lt;/dbobject&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/b7326baf177eb21f6704.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;3. Changes in Admin login (R2D_login.java) activity&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In this layout of this activity we add two new buttons to the activity_r2d_login.xml file.They are named Update &amp;amp; Delete.&lt;/li&gt;
&lt;li&gt;We bind the variable created in r2d_login.java , to the xml elements using findViewById() method. The methods under the corresponding onClickListner s &amp;amp; other are explained at the end in the last section.&lt;/li&gt;
&lt;li&gt;For now just copy &amp;amp; paste the code if you want to.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/dc8781e2b4255ff2f428.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;4. Create a new activity named Update_form&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;This activity uses the layout of our MainActivity so we don&#39;t need to create &amp;nbsp;a separate xml layout for this. If one is created, just delete it.&lt;/li&gt;
&lt;li&gt;We re-use the layout by just setting it in the setContentView() method. We also change the text displayed on the button using the setText(&quot; string &quot;) method on the button object.&lt;/li&gt;
&lt;li&gt;In the onClickListner() of the button, we call the same function used in the MainActivity to for the basic form verification.The only difference here is instead of inserting into the table we update the selected (selected in the r2d_login activity )user&#39; s info.&lt;/li&gt;
&lt;li&gt;To help us do this we used the intuitive method on putting extras into the intents. We put the id of the user when selected in r2d_login activity &amp;amp; put it in the intent using &lt;intent&gt;.putExtra(&quot;name&quot;,value) method.&lt;/intent&gt;&lt;/li&gt;
&lt;li&gt;We get the extra value back using the getExtras().get(&quot;id&quot;) method. Then we simply call the update_user method with mail_id, pass &amp;amp; id from intent.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Finally we close the activity using finish() method.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/c8d7204a003cf27e6283.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;5. Run the project&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: right;&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Simply run the app using CTRL+F11.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZClzwq7W1MDgsgCjUspNB10DgQ8UersUQWKD5I1KYGEk6g4VPdx29lnriZ1Z4o0oeqWzGR-y_7celkb49a2bhAOkLfsSlMcX9-vj_5o9PkQpxAqZx0MiX2O7DXi7dIhMHGC68JxtKh3A/s1600/DFG_2014-10-01-19-14-08.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZClzwq7W1MDgsgCjUspNB10DgQ8UersUQWKD5I1KYGEk6g4VPdx29lnriZ1Z4o0oeqWzGR-y_7celkb49a2bhAOkLfsSlMcX9-vj_5o9PkQpxAqZx0MiX2O7DXi7dIhMHGC68JxtKh3A/s1600/DFG_2014-10-01-19-14-08.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmiqMSGzaGWuLb8X5Z_e3BbetL6YAZVLAd_uNLZh2E0P_9R-ZWjloN3KJn1ls1CKdTXqvrcSYTYNPTl_WaOGGpoAAQINpm4_4lM6IWKdaO2HhiIl_O9RvNe1qMATS6-fBEjpAQ3osuyM4/s1600/DFG_2014-09-29-00-55-12.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjmiqMSGzaGWuLb8X5Z_e3BbetL6YAZVLAd_uNLZh2E0P_9R-ZWjloN3KJn1ls1CKdTXqvrcSYTYNPTl_WaOGGpoAAQINpm4_4lM6IWKdaO2HhiIl_O9RvNe1qMATS6-fBEjpAQ3osuyM4/s1600/DFG_2014-09-29-00-55-12.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Admin login id&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirjMnISzSyG0gEWVPbYJZd2LrDxgESvH_5bqyZ-BlJTf81sfXXsM0a1xBOcr_21h8AqssEv134qDJyIVrn3rm2KT9VLQCtNJqS933_Bqx0gXS9uxAHzk0ktks4lNvbvNJNXGfDd9fTbGk/s1600/DFG_2014-10-01-19-13-53.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: right;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirjMnISzSyG0gEWVPbYJZd2LrDxgESvH_5bqyZ-BlJTf81sfXXsM0a1xBOcr_21h8AqssEv134qDJyIVrn3rm2KT9VLQCtNJqS933_Bqx0gXS9uxAHzk0ktks4lNvbvNJNXGfDd9fTbGk/s1600/DFG_2014-10-01-19-13-53.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Users in database&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZClzwq7W1MDgsgCjUspNB10DgQ8UersUQWKD5I1KYGEk6g4VPdx29lnriZ1Z4o0oeqWzGR-y_7celkb49a2bhAOkLfsSlMcX9-vj_5o9PkQpxAqZx0MiX2O7DXi7dIhMHGC68JxtKh3A/s1600/DFG_2014-10-01-19-14-08.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZClzwq7W1MDgsgCjUspNB10DgQ8UersUQWKD5I1KYGEk6g4VPdx29lnriZ1Z4o0oeqWzGR-y_7celkb49a2bhAOkLfsSlMcX9-vj_5o9PkQpxAqZx0MiX2O7DXi7dIhMHGC68JxtKh3A/s1600/DFG_2014-10-01-19-14-08.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Try select more than one user&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVVyJb0P6OyDZ6JGVgo63-hGNFa0HkPXmX1weV9ueA5CoxxpPYKFWTn-5S5FIL50h1XpMhtEu1jff5XUdXWndSDoSJ_PY5632WkQOuqHQrLvpiaw2aZz9Giuu6kN0tYwxyMviliGcQefM/s1600/DFG_2014-10-01-19-14-02.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVVyJb0P6OyDZ6JGVgo63-hGNFa0HkPXmX1weV9ueA5CoxxpPYKFWTn-5S5FIL50h1XpMhtEu1jff5XUdXWndSDoSJ_PY5632WkQOuqHQrLvpiaw2aZz9Giuu6kN0tYwxyMviliGcQefM/s1600/DFG_2014-10-01-19-14-02.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Get a notification&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdKixngzKLOt33_vmPSZXRIdzlVFb5r_eon-DZjXccdCy2Q0eND20L75FLw-IFOJjDD39HYEzRx9zIoxbhgGwWn1bNlvFHf_FFoTKSuUrpNASd2hUWDXydVIs-2DRFZESS3pHXJ4lyJi4/s1600/DFG_2014-10-01-19-14-16.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdKixngzKLOt33_vmPSZXRIdzlVFb5r_eon-DZjXccdCy2Q0eND20L75FLw-IFOJjDD39HYEzRx9zIoxbhgGwWn1bNlvFHf_FFoTKSuUrpNASd2hUWDXydVIs-2DRFZESS3pHXJ4lyJi4/s1600/DFG_2014-10-01-19-14-16.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Select a user to update&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFppNNdwLd_uMXnkr4dIfsHlOmQ6Xmxrr_PyLCZ_97FdiKoPIKqbnFFAgpCSIxJpPIG05zluFRcqH3lt9FirxZjuTEbAPuy1KUdeX-Im3KfEGj69Gks6Ve2UYOvOVA24hsBEkOQyxVHuE/s1600/DFG_2014-10-01-19-14-29.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjFppNNdwLd_uMXnkr4dIfsHlOmQ6Xmxrr_PyLCZ_97FdiKoPIKqbnFFAgpCSIxJpPIG05zluFRcqH3lt9FirxZjuTEbAPuy1KUdeX-Im3KfEGj69Gks6Ve2UYOvOVA24hsBEkOQyxVHuE/s1600/DFG_2014-10-01-19-14-29.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Enter new details &amp;amp; Update&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTQx59q4PIeGmqxK2zTB71jq4rxSTXuorZ1idaNbqJqVS2Ne1e0XdKkJLIJqWBGSepF-WrFEFGGacPjnps7fW0DCWgdT8NrCj1rJLY49zf8j0-PPUQ9fDALlukjFqFx2KrcFcaXKag6z8/s1600/DFG_2014-10-01-19-15-22.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTQx59q4PIeGmqxK2zTB71jq4rxSTXuorZ1idaNbqJqVS2Ne1e0XdKkJLIJqWBGSepF-WrFEFGGacPjnps7fW0DCWgdT8NrCj1rJLY49zf8j0-PPUQ9fDALlukjFqFx2KrcFcaXKag6z8/s1600/DFG_2014-10-01-19-15-22.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Updated list&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: right; margin-left: 1em; text-align: right;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9JEd2BTInlhfDqVKLefLLpf6BRjA-qZcuPsDYv1zqvw5EVmRTeULnmcIhtcizhy_qk6IJ0srJteichKUSXsuBTgytnaU5f9plb_f1sX5e8o1Hgct-wR5r5UsNpP3v3uxbzScBr2ZM2Hs/s1600/DFG_2014-10-01-19-15-31.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9JEd2BTInlhfDqVKLefLLpf6BRjA-qZcuPsDYv1zqvw5EVmRTeULnmcIhtcizhy_qk6IJ0srJteichKUSXsuBTgytnaU5f9plb_f1sX5e8o1Hgct-wR5r5UsNpP3v3uxbzScBr2ZM2Hs/s1600/DFG_2014-10-01-19-15-31.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Select users to delete&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKt8VsSxRQc2cA8SEQengbKW9q3-M6ldzreekwTrRHRE_aimG1496RvpQ7OW8scqYQ9unX6blo-vhumPn2hcH36TVD0s-iP7mq1JKBUqwKHU0jnJdD9TXqZonf3G8Nlr8NwwmlLrNTOQ4/s1600/DFG_2014-10-01-19-15-37.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiKt8VsSxRQc2cA8SEQengbKW9q3-M6ldzreekwTrRHRE_aimG1496RvpQ7OW8scqYQ9unX6blo-vhumPn2hcH36TVD0s-iP7mq1JKBUqwKHU0jnJdD9TXqZonf3G8Nlr8NwwmlLrNTOQ4/s1600/DFG_2014-10-01-19-15-37.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;List after deletion&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Code Explained:&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The methods update_user and delete_user are quite straight forward. They are explained in point 2 above.&lt;/li&gt;
&lt;li&gt;The main magic happens in the r2d_login activity.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;The overridden onResume() method calls the update_list() method in which we just create a new arrayadapater and use show_in_list() method (as in previous post) to initialize the list. We then set the grid view with the array adapter.&lt;/li&gt;
&lt;li&gt;Both the onClickListner s of the buttons use their own logics by calling remove_logic() &amp;amp; update_logic() respectively. They also call the same update_list() method to make updation happen.&lt;/li&gt;
&lt;li&gt;In the remove_logic() method we first create a SparseBooleanArray and set to checked grid positions as before. We then loop through the arrayadapater and check if the item is checked. If its checked we get its id by getting &amp;nbsp;the characters from the list data up to the first space (&#39; &#39;). This is done using the substring() method.We then call the delete_user(user_id) method.&lt;/li&gt;
&lt;li&gt;The update logic is more or less the same. The only difference is that we first check if more than one list item is checked &amp;amp; if so we prompt the user.&lt;/li&gt;
&lt;li&gt;Then using the same looping logic we find the checked list item id and put it int the extras field and start the activity.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Download&amp;nbsp;Code:&lt;/span&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/spdugn1kos2kxdk/AABehROomIoy5JjAhnNmj1XIa?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheL8pHZo2Th4Rb5IvjzHdFpj5S2Pqs2G_X6vYfxF62qZCCvunLVOh7ElPXLRw9-PPBNh9oOM7m1hJ70UedrNbl6T2SzyujjetWhhAvs2wHj2nl-AAMduHpWptTnYAm1d3npQCr7S9v2iI/s1600/unnamed.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://roadtodroid.blogspot.com/2014/10/android-database-part-ii.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj4nPt9d5d5S81chOtCcM58Ah3KWHdVA7DKnGhPVSbm-r4aEBcMNt5MXKl6Lqh0m-BfzApycGpWdSn841C9S2kTII7XVlYF15Pp5RvhoTUfKs5YgQ7_-tewRA3ciWc8TP1ZSDJz-8lclSU/s72-c/android+database+part+2.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-897049588831259017</guid><pubDate>Mon, 29 Sep 2014 12:33:00 +0000</pubDate><atom:updated>2014-09-29T05:46:29.267-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Basics</category><category domain="http://www.blogger.com/atom/ns#">Android Database Part I</category><category domain="http://www.blogger.com/atom/ns#">Database</category><category domain="http://www.blogger.com/atom/ns#">Email Validation</category><category domain="http://www.blogger.com/atom/ns#">Form</category><category domain="http://www.blogger.com/atom/ns#">Grid View</category><category domain="http://www.blogger.com/atom/ns#">Insert in database</category><category domain="http://www.blogger.com/atom/ns#">Pattern Matching</category><category domain="http://www.blogger.com/atom/ns#">Retrieve from database</category><title>Android Database Part I</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3v7x2NkCR00f8N25gr6wHhMwqhxz3-iep40yQfDO3zJnrulml3ezGdYKRLCbq7RS07ykMgux_eVemNMv2-IHtNkxX7JcrDT-wXsbP6T0ql3icyRCEzcjs4Pz4kNlUsuMJUIaocSQoouo/s1600/Database+part+1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3v7x2NkCR00f8N25gr6wHhMwqhxz3-iep40yQfDO3zJnrulml3ezGdYKRLCbq7RS07ykMgux_eVemNMv2-IHtNkxX7JcrDT-wXsbP6T0ql3icyRCEzcjs4Pz4kNlUsuMJUIaocSQoouo/s1600/Database+part+1.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Welcome again to road to droid. In this section I am going to discuss about the the ways to implement a SQLite database on you android device. To demonstrate the concept I am creating an app which makes user fill a form and then inserts the details into a database. So hop in for a ride!&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;1. Create a new Android Application Project&lt;/span&gt;&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;li&gt;Fill in the name for the app as you like and click Next.&lt;/li&gt;
&lt;li&gt;In the next few dialogs click Next and in the one with Activity Types select Empty Activity.&lt;/li&gt;
&lt;li&gt;In the final dialog box click Finish.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYU5na796x14ev0R0NfiTPgCzfYlxQ5wsog2tVOKWhig_6n0RgDbCXEGv2M7IpopzypM0G9geyb8PeuY0K9i76tT1Q1XtO9Fscw52FxfUPNnW-Ns1BjY6alwaFEPlAIX-vExVoBC8CVko/s1600/app_name1.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYU5na796x14ev0R0NfiTPgCzfYlxQ5wsog2tVOKWhig_6n0RgDbCXEGv2M7IpopzypM0G9geyb8PeuY0K9i76tT1Q1XtO9Fscw52FxfUPNnW-Ns1BjY6alwaFEPlAIX-vExVoBC8CVko/s1600/app_name1.PNG&quot; height=&quot;338&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Enter a name for the app&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;2. Add elements to the activity_main.xml file&lt;/span&gt;&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the activity_main.xml file (name may be different in case you named your main activity differently), add two EditTexts &amp;amp; one Button. (I have also added two ImageViews for the Mail &amp;amp; Password fields, you may omit them).&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Insert a android:hint &amp;nbsp;field to give hints on what to enter in the EditTexts.&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc42ptKliQXe5pFsLGv8pLl6Qhn2FQ7d5dFkz1J0CWgSc80ApXdnt2V14QyiSg9kHWMflmUFFoIAvLKBp3ga8ZesuqjDRL8etLaRre5uAfUN_SlJhjcEy2sPj3qEOGpl_Eu79XRB_W3Ew/s1600/main_xml.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc42ptKliQXe5pFsLGv8pLl6Qhn2FQ7d5dFkz1J0CWgSc80ApXdnt2V14QyiSg9kHWMflmUFFoIAvLKBp3ga8ZesuqjDRL8etLaRre5uAfUN_SlJhjcEy2sPj3qEOGpl_Eu79XRB_W3Ew/s1600/main_xml.PNG&quot; height=&quot;400&quot; width=&quot;236&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Graphical Layout&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/c423845efa5c91f89315.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;3. Add a DbHelper class to the package&lt;/span&gt;&amp;nbsp;&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Right Click on the package under the src folder in your apps Package Explorer and add a new Class to it.&lt;/li&gt;
&lt;li&gt;This class extends SQLiteOpenHelper which encapsulates all methods for creating and managing SQLite database in android.&lt;/li&gt;
&lt;li&gt;For more explanation go to the end of the post to the Code Explained section.&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHJS5tM6bcpIm_Lt7AxtmDo0xxSKbk8EchK4c14j0I7mi2JSs01PGH1aSv3N6uyAc0fgIJ906Zx9DScXzhQLxTDtODWat3FXVkWsbOX6jJ6NjMX29G2q7ZQ_ihnm5NLUxx8f_G1vl1uH8/s1600/dbhelper.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHJS5tM6bcpIm_Lt7AxtmDo0xxSKbk8EchK4c14j0I7mi2JSs01PGH1aSv3N6uyAc0fgIJ906Zx9DScXzhQLxTDtODWat3FXVkWsbOX6jJ6NjMX29G2q7ZQ_ihnm5NLUxx8f_G1vl1uH8/s1600/dbhelper.PNG&quot; height=&quot;400&quot; width=&quot;338&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;My_DbHelper class creation&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/0c9682fdb5e2cd2b9b64.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;4. Code away the MainActivity.java&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In our main activity we first create an object of My_DbHelper to handle database operations.&lt;/li&gt;
&lt;li&gt;In onCreate() we bind the layout elements to variables and in the onClickListner of the button we check if the EditTexts are empty by using &lt;edittext&gt;.getText().toString().equalsIgnoreCase(&quot;&quot;).&lt;/edittext&gt;&lt;/li&gt;
&lt;li&gt;If the both the fields are not empty then we check if there is a Admin login attempt with &quot;r2d&quot; as both mail id and password . If so we empty the EditTexts (using setText()) and launch an Intent to another activity which we will create below.&lt;/li&gt;
&lt;li&gt;We also check for the validity of the email id entered using a regular expression. The .match(regex) method returns true if there is match.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/e7debddc6f8bf6bc56b0.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;5. Add an Admin login portal for the next tutorial&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Add another Android activity to the package by right clicking it and selecting New &amp;gt; Other &amp;gt; Android Activity.&lt;/li&gt;
&lt;li&gt;The implementation of this activity is same as that demonstrated in previous posts on List Views.The only difference is in the show_in_list() method which uses an object of My_DbHelper to get all users in the database using the method we created (get_all_user()).&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/9dba5d76095880aae3f9.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;6. Enter GridView to xml of Admin login activity&lt;/span&gt;&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the xml file of this new activity add a grid view to show the entries of the database.&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWkStf1TYB0eYo9k3_DDG8qGHG_-hk-fQQLZO74n_x1-oDVGGtC-_297v_oXlrv2ZDaxoZFkgWPFOf6_ixnPGu2uhEIuTQUGXGXYDkhCCV2edRp0BUlGM_HXHzgNWtuX2gLqMHUlqOeHc/s1600/r2dlogin_xml.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWkStf1TYB0eYo9k3_DDG8qGHG_-hk-fQQLZO74n_x1-oDVGGtC-_297v_oXlrv2ZDaxoZFkgWPFOf6_ixnPGu2uhEIuTQUGXGXYDkhCCV2edRp0BUlGM_HXHzgNWtuX2gLqMHUlqOeHc/s1600/r2dlogin_xml.PNG&quot; height=&quot;400&quot; width=&quot;236&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Grid View&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/e5cd6cb9ccac5d009cca.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;7. Run the App&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Launch the app on an AVD or on a physical device by pressing CTRL&amp;nbsp;+ F11.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyqA2slA29WW0HDkXtp6KQoW9Gl9uq4MYYUD-vQIH4U5ukjFsR7aHLwsWqpRXLj5ahGqhr8kRJ4KwMkVYILrO_i3b4eUTKlMSAuaQUU9xTYbuPuTg43Fzye4t3Py3TWxNrEWpi5bTkGgw/s1600/DFG_2014-09-29-00-53-52.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyqA2slA29WW0HDkXtp6KQoW9Gl9uq4MYYUD-vQIH4U5ukjFsR7aHLwsWqpRXLj5ahGqhr8kRJ4KwMkVYILrO_i3b4eUTKlMSAuaQUU9xTYbuPuTg43Fzye4t3Py3TWxNrEWpi5bTkGgw/s1600/DFG_2014-09-29-00-53-52.png&quot; height=&quot;640&quot; width=&quot;380&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJavphd3BPo-0abUL-OTkL5q3JZFPD-GvRyZBMDCHDgEZKyi9bN6irh-OR_4r5_FXIPj4qCJq_5irei7VJaFWMiyr0PAwSB2DW0gerGdD2Hm28jrTkhaTlB7wn6DDKFguya__JkER3O1Y/s1600/DFG_2014-09-29-00-53-58.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJavphd3BPo-0abUL-OTkL5q3JZFPD-GvRyZBMDCHDgEZKyi9bN6irh-OR_4r5_FXIPj4qCJq_5irei7VJaFWMiyr0PAwSB2DW0gerGdD2Hm28jrTkhaTlB7wn6DDKFguya__JkER3O1Y/s1600/DFG_2014-09-29-00-53-58.png&quot; height=&quot;640&quot; width=&quot;382&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUjBZvSLtFmB3Uk7PIMiHQU7TkEncGoTVvMEzlvoX0-IzcQ2cRJ-KqWWNFIFQa7O7sS5SbLyat0edcHkF1GTwiOHLLeWgv-oJHbqVGSnraBm0HMfN_hSXDoBpMElHiMKDei3RnQ7TYa7I/s1600/DFG_2014-09-29-00-55-12.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUjBZvSLtFmB3Uk7PIMiHQU7TkEncGoTVvMEzlvoX0-IzcQ2cRJ-KqWWNFIFQa7O7sS5SbLyat0edcHkF1GTwiOHLLeWgv-oJHbqVGSnraBm0HMfN_hSXDoBpMElHiMKDei3RnQ7TYa7I/s1600/DFG_2014-09-29-00-55-12.png&quot; height=&quot;640&quot; width=&quot;382&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbawg_bW2qNnZF_fn870ciZ-sVX3COhiDMxwRErMK1Okzm4yGwo4X0rGACouXme5n7pW_inZ2H7Wzt6HFIkKf7tPl1sTx1zQmyKP6geqbmKK2lCu4yCbwaALg2M3NwlNxzRoWgHy7JOw0/s1600/DFG_2014-09-29-00-54-09.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbawg_bW2qNnZF_fn870ciZ-sVX3COhiDMxwRErMK1Okzm4yGwo4X0rGACouXme5n7pW_inZ2H7Wzt6HFIkKf7tPl1sTx1zQmyKP6geqbmKK2lCu4yCbwaALg2M3NwlNxzRoWgHy7JOw0/s1600/DFG_2014-09-29-00-54-09.png&quot; height=&quot;640&quot; width=&quot;382&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: #4c1130;&quot;&gt;Code Explained:&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the My_DbHelper class which extends a SQLiteOpenHelper to&amp;nbsp;manage database creation&amp;nbsp;and version management. For more on SQLiteOpenHelper go to&amp;nbsp;&lt;a href=&quot;http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html&quot;&gt;http://developer.android.com/reference/android/database/sqlite/SQLiteOpenHelper.html&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In the class the DATABASE_VERSION variable is used if we have several versions or instances of our database.We can change the version at any time or save any version for future use.For assign any number to this variable.&lt;/li&gt;
&lt;li&gt;The String variables DATABASE_NAME &amp;amp; TABLE_NAME are used to give a name to our database and to a table in it. You can have more than one tables in your database. Create a new String to store each ones name.&lt;/li&gt;
&lt;li&gt;Now we create a String query to create a new table.We define three attributes for any tuple. One is &#39;user_id&#39; which is of type INTEGER and is set to AUTOINCREMENT, also it is the PRIMARY KEY for the table. Another attribute is &#39;mail_id&#39; which is of type TEXT and is set to NOT NULL. The is the case for the attribute &#39;pass&#39;.&lt;/li&gt;
&lt;li&gt;In the &lt;span style=&quot;color: #6aa84f;&quot;&gt;onCreate()&lt;/span&gt; method of the class we create the table using&lt;span style=&quot;color: #6aa84f;&quot;&gt; execSQL(&lt;query&gt;)&lt;/query&gt;&lt;/span&gt; method.&lt;/li&gt;
&lt;li&gt;In the &lt;span style=&quot;color: #6aa84f;&quot;&gt;onUpgrade()&lt;/span&gt; method we can either load an older version of the database or just drop everything and create a new one. And that is what we have done here.&lt;/li&gt;
&lt;li&gt;We have also created two methods to insert tuples into the table &amp;amp; to retrieve tuples from the table.&lt;/li&gt;
&lt;li&gt;The insert_user(String ,String) method takes as argument two strings and inserts them into the table using a ContentValues object. First we get a SQLiteDatabase object for our table in the writable mode using &lt;span style=&quot;color: #6aa84f;&quot;&gt;getWritableDatabase()&lt;/span&gt; method.&lt;/li&gt;
&lt;li&gt;We create a new ContentValues object and put in it the Strings m &amp;amp; p with the respective attribute names for the table. Note we didn&#39;t put the user_id in values as it is set to AUTOINCREMENT. Finally we insert the values into the table using &lt;span style=&quot;color: #6aa84f;&quot;&gt;insert()&lt;/span&gt; method.&lt;/li&gt;
&lt;li&gt;In the get_all_user method we first define a List&lt;string&gt; ro store all the tuples in the database in string form. Then we create the search query which is SELECT * FORM TABLE_NAME.&lt;/string&gt;&lt;/li&gt;
&lt;li&gt;Now we get a SQLiteDatabase object which is only readable using getReadableDatabase() method. We then create a cursor to move around in our table. A cursor is just like a pointer to the tuples in the table.&lt;/li&gt;
&lt;li&gt;We move this cursor forward into the table using &lt;span style=&quot;color: #6aa84f;&quot;&gt;moveToNext() &lt;/span&gt;on cursor object. We first also make sure if the cursor is at the starting of the table by calling &lt;span style=&quot;color: #6aa84f;&quot;&gt;moveToFirst()&lt;/span&gt; on cursor, Finally we go in a loop to get user_id, mail_id &amp;amp; pass from the cursor using &lt;span style=&quot;color: #6aa84f;&quot;&gt;getString()/getInt()&lt;/span&gt; &amp;amp; &lt;span style=&quot;color: #6aa84f;&quot;&gt;getColumnIndex()&lt;/span&gt; methods. We add each of these values to out List&lt;string&gt; object.&lt;/string&gt;&lt;/li&gt;
&lt;li&gt;Finally we return the List to the calling Activity.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Download Code:&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/bltqwwnwd6w0fvb/AABnR1QV8O66_t9GMKToohJ-a?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheL8pHZo2Th4Rb5IvjzHdFpj5S2Pqs2G_X6vYfxF62qZCCvunLVOh7ElPXLRw9-PPBNh9oOM7m1hJ70UedrNbl6T2SzyujjetWhhAvs2wHj2nl-AAMduHpWptTnYAm1d3npQCr7S9v2iI/s1600/unnamed.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/09/android-database-part-i.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3v7x2NkCR00f8N25gr6wHhMwqhxz3-iep40yQfDO3zJnrulml3ezGdYKRLCbq7RS07ykMgux_eVemNMv2-IHtNkxX7JcrDT-wXsbP6T0ql3icyRCEzcjs4Pz4kNlUsuMJUIaocSQoouo/s72-c/Database+part+1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-4671369478474806574</guid><pubDate>Sat, 27 Sep 2014 17:43:00 +0000</pubDate><atom:updated>2014-09-27T10:48:38.375-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Activity LifeCycle</category><category domain="http://www.blogger.com/atom/ns#">life cycle</category><category domain="http://www.blogger.com/atom/ns#">Tips &amp; Tricks</category><title>Android Activity Life Cycle</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggs6actXQm8fYH7eAtLebLXyy2AsfXvAI74boUY1BhMYx9-TNRZgkA0LCWbETgYxedzR_VXCr73amNzaVZe5tieThCUuaOQe9Ylb6QxLjgxhspDms4ca8OPV7TRrhdhanoWcxKXSF7Gxc/s1600/new-prof.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggs6actXQm8fYH7eAtLebLXyy2AsfXvAI74boUY1BhMYx9-TNRZgkA0LCWbETgYxedzR_VXCr73amNzaVZe5tieThCUuaOQe9Ylb6QxLjgxhspDms4ca8OPV7TRrhdhanoWcxKXSF7Gxc/s1600/new-prof.png&quot; height=&quot;275&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
In this section I am going to discuss the activity life cycle.So let us first wrap our heads around the concept of activities in Android.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;What&#39;s an Activity?&lt;/span&gt;&lt;/h2&gt;
Activities are an unusual programming concept specific to Android. In traditional application development there is usually a static main method, which is executed to launch the application. With Android, however, things are different; Android applications can be launched via any registered activity within an application. &lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;What&#39;s an Activity&#39;s Lifecycle?&lt;/span&gt;&lt;/h2&gt;
The Android activity life-cycle comprises a collection of methods exposed within the Activity class that provide the developer with a resource management framework. This framework allows developers to meet the unique state management requirements of each activity within an application and properly handle resource management.&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
When an activity’s state is changing, the activity is notified by the OS, which calls specific methods on that activity. The following diagram illustrates these methods in relationship to the Activity Lifecycle:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimQgkdsGJg560jHneyL0sQoUB4xHPI0i1eeAzq3cX7-IQ2NIgOWQCNw8Tyd0hlRpaw3mlYbEeTTw_gmWIAb7LNXWrFLhwt80eaHE1VE-s6AT5MvUv5_D8aaWYVOjOO4v6ZCTB-U9FwFK8/s1600/basic-lifecycle.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimQgkdsGJg560jHneyL0sQoUB4xHPI0i1eeAzq3cX7-IQ2NIgOWQCNw8Tyd0hlRpaw3mlYbEeTTw_gmWIAb7LNXWrFLhwt80eaHE1VE-s6AT5MvUv5_D8aaWYVOjOO4v6ZCTB-U9FwFK8/s1600/basic-lifecycle.png&quot; height=&quot;283&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Start-up&amp;nbsp;Sequence:&lt;/span&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;OnCreate&lt;/b&gt;: &amp;nbsp;Called when the activity is first created. This is where you should do all of your normal static set up: create views, bind data to lists, etc. This method also provides you with a Bundle containing the activity&#39;s previously frozen state, if there was one. Always followed by onStart().&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OnStart&lt;/b&gt;: Called when the activity is becoming visible to the user. Followed by onResume() if the activity comes to the foreground, or onStop() if it becomes hidden.&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OnResume&lt;/b&gt;:&amp;nbsp;Called when the activity will start interacting with the user. At this point your activity is at the top of the activity stack, with user input going to it. Always followed by onPause().&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Configuration Change Sequence:&lt;/span&gt;&lt;/h3&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;OnPause&lt;/b&gt;:&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.8048000335693px;&quot;&gt;Called as part of the activity lifecycle when an activity is going into the background, but has not (yet) been killed. The counterpart to onResume().&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OnStop:&lt;/b&gt;&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.8048000335693px;&quot;&gt;Called when you are no longer visible to the user. You will next receive either onRestart(), onDestroy(), or nothing, depending on later user activity.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OnDestroy&lt;/b&gt;:&amp;nbsp;&lt;span style=&quot;background-color: #eeeeee; font-family: Arial, &#39;Liberation Sans&#39;, &#39;DejaVu Sans&#39;, sans-serif; font-size: 14px; line-height: 17.8048000335693px;&quot;&gt;The final call you receive before your activity is destroyed. This can happen either because the activity is finishing (someone called finish() on it, or because the system is temporarily destroying this instance of the activity to save space&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OnCreate&lt;/b&gt; : (Same as before)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OnSart&lt;/b&gt;&amp;nbsp;&amp;nbsp;: (Same as before)&lt;/li&gt;
&lt;li&gt;&lt;b&gt;OnResume&lt;/b&gt;&amp;nbsp;: (Same as before)&lt;/li&gt;
&lt;/ol&gt;
For more detailed information on activity life-cycle refer the following links:&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.xamarin.com/guides/android/application_fundamentals/activity_lifecycle/&quot;&gt;http://developer.xamarin.com/guides/android/application_fundamentals/activity_lifecycle/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://developer.android.com/training/basics/activity-lifecycle/index.html&quot;&gt;http://developer.android.com/training/basics/activity-lifecycle/index.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://thenewcircle.com/s/post/1178/architecting_android_apps&quot;&gt;https://thenewcircle.com/s/post/1178/architecting_android_apps&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
Or watch these videos on YouTube:&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=-G91Hp3t6sg&quot;&gt;https://www.youtube.com/watch?v=-G91Hp3t6sg&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.youtube.com/watch?v=h69WDWZdqi4&quot;&gt;https://www.youtube.com/watch?v=h69WDWZdqi4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;Hope this helped you! Continue reading.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/09/android-activity-life-cycle.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggs6actXQm8fYH7eAtLebLXyy2AsfXvAI74boUY1BhMYx9-TNRZgkA0LCWbETgYxedzR_VXCr73amNzaVZe5tieThCUuaOQe9Ylb6QxLjgxhspDms4ca8OPV7TRrhdhanoWcxKXSF7Gxc/s72-c/new-prof.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-5669487618609744384</guid><pubDate>Tue, 23 Sep 2014 19:09:00 +0000</pubDate><atom:updated>2014-09-28T11:47:51.591-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Basics</category><category domain="http://www.blogger.com/atom/ns#">Android List view Part 3</category><category domain="http://www.blogger.com/atom/ns#">Custom Adapter</category><category domain="http://www.blogger.com/atom/ns#">getView</category><category domain="http://www.blogger.com/atom/ns#">setTag</category><category domain="http://www.blogger.com/atom/ns#">View Holder</category><title>Android ListView Part III</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsHkuRwPyxES9KVhjelf6uLv8EnppUzgZdswqbbz4v3W87uc4oIFq2wChfYlVmwgY3b_T6eGtzI9woz357xUn6MbWt9ukDJz8w1Q_I2sXQCYow-gHbKyQrbRLYA6oQobNZIIuLFri7Q3k/s1600/Android+List+view+part+3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsHkuRwPyxES9KVhjelf6uLv8EnppUzgZdswqbbz4v3W87uc4oIFq2wChfYlVmwgY3b_T6eGtzI9woz357xUn6MbWt9ukDJz8w1Q_I2sXQCYow-gHbKyQrbRLYA6oQobNZIIuLFri7Q3k/s1600/Android+List+view+part+3.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Hi everyone! Welcome again to roadtodroid for another fun Android tutorial. In this post I am gonna tech you how to create your own customized list views. Along the way some new things such the vibrator class and the action bar methods are also introduced. So let&#39;s start building this fun app.&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;1. Create a new Android Application Project&lt;/span&gt;&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;li&gt;Give a suitable name and proceed as before.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkA_Cv8yMOJYP8ky-LooRrACg9MHvJhPi8zIxu-FEN8LNAE2ggUxDmqIjgUeF8zK0BYgGE1faRxDDiJVqkoW7L3X5rs-E4QMWEs7o5DThrpQVNVzzbNS_ii4g1WGybkIHs1YOdOvzgz1Q/s1600/app_name.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhkA_Cv8yMOJYP8ky-LooRrACg9MHvJhPi8zIxu-FEN8LNAE2ggUxDmqIjgUeF8zK0BYgGE1faRxDDiJVqkoW7L3X5rs-E4QMWEs7o5DThrpQVNVzzbNS_ii4g1WGybkIHs1YOdOvzgz1Q/s1600/app_name.PNG&quot; height=&quot;342&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;New app dialog&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;2. Add a ListView to activity_main.xml&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;From the palette, go to the composite tab and select a ListView from there. Place it inside the graphical layout in activty_main.xml.&lt;/li&gt;
&lt;li&gt;Remember to make the android:id=&quot;@android:id./list&quot;.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBjqQtBJVaNEX_x_MJqizxRqx8lmCfVugJjEoNW20k8bxjsslEUQKYiKs_cbaSfeVPU3kn7qdK2PLuSug71n2JNVhP5lC9wYC0yrvIp7S3fd9dGtuDoI_nJqDyoZR5tMjDW_thFZPNoQ0/s1600/main_xml.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBjqQtBJVaNEX_x_MJqizxRqx8lmCfVugJjEoNW20k8bxjsslEUQKYiKs_cbaSfeVPU3kn7qdK2PLuSug71n2JNVhP5lC9wYC0yrvIp7S3fd9dGtuDoI_nJqDyoZR5tMjDW_thFZPNoQ0/s1600/main_xml.PNG&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;activity_main.xml&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/0ebcb956bacf40e5bf29.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: #6aa84f;&quot;&gt;3. Create a rowlayout.xml file&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In the Package Explorer, under you app folder, add a new rowlayout.xml to res/ layout folder (where activity_main.xml is present).&lt;/li&gt;
&lt;li&gt;To do this right-click on layout folder and go to new and select Android XML File.&lt;/li&gt;
&lt;li&gt;In the rowlayout.xml file add the following code, to add an image and text to our list adapter.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/7e56497016ee3b6c1b1d.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;
4. Create the Custom Adapter MyCustomAdapter.java&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Now its&#39; time to define the view of the list according to our needs. So go to the src folder under our project name in the package present right-click and add a new Class to it.&lt;/li&gt;
&lt;li&gt;For now just copy the code below and change the package name to your&#39;s package name. For more explanation check the bottom of the post.&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJgvkBbnIIX2_12E-OfMV6UzlYjFXUqdBvhOxzJweTjptwPJIivDoOdBItUsnW_zklNphPm-EsN0BXooxrDohX_LwYEgWJPiejmVV73x6zBtlY5t6dkIPCgpwlGZ-N0Cj5txbvx08rihc/s1600/new_class_main.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJgvkBbnIIX2_12E-OfMV6UzlYjFXUqdBvhOxzJweTjptwPJIivDoOdBItUsnW_zklNphPm-EsN0BXooxrDohX_LwYEgWJPiejmVV73x6zBtlY5t6dkIPCgpwlGZ-N0Cj5txbvx08rihc/s1600/new_class_main.PNG&quot; height=&quot;400&quot; width=&quot;340&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Adding new Custom Adapter Class&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/0eb9aa3bc5ed9c282109.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;5. Code the MainActivity.java&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In our main java file we first make our main class extend ListActivity to get all list handling functionality.&lt;/li&gt;
&lt;li&gt;Then we made an object of our Custom Adapter and sent the values to it.&lt;/li&gt;
&lt;li&gt;Finally we set the Custom Adapter to our list.&lt;/li&gt;
&lt;li&gt;Also onListItemClick &amp;nbsp;is also used to do some processing when the list item is clicked.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/cc07b8703e0bd281e533.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #6aa84f;&quot;&gt;&amp;nbsp;6. Run the app&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Launch the app by pressing CTRL+F11.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;A physical device can be connected through USB or an AVD can be configured as shown in &amp;nbsp;&lt;a href=&quot;http://roadtodroid.blogspot.in/2014/09/lets-start-with-setting-up-with.html&quot;&gt;http://roadtodroid.blogspot.in/2014/09/lets-start-with-setting-up-with.html&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWd19-_DTT0oGz5gTzvM46Oo1O2yLYzUNG0bTfXn3EmI-MzIAVXvTjVgIlMV5VC8S-OCGUAPU4wq3bC-AIJdCf5ySw8f24uwFCO3lEAW_eeUloGIP2YkCxYJCikBAPRsxDj0szmQHdRBk/s1600/DFG_2014-09-23-22-52-32.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiWd19-_DTT0oGz5gTzvM46Oo1O2yLYzUNG0bTfXn3EmI-MzIAVXvTjVgIlMV5VC8S-OCGUAPU4wq3bC-AIJdCf5ySw8f24uwFCO3lEAW_eeUloGIP2YkCxYJCikBAPRsxDj0szmQHdRBk/s1600/DFG_2014-09-23-22-52-32.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Launch page&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8nCI8NkLyOjMfopasce-jPw9tKSh7ndM3QK7q28K0jxzzmRvosMd-IOWBBSj4ided-bpNK6Hzm1nhjaxt6miype19epSS-URhIN30UhH90jk0q_rqDcPfzWIU53MnarmTH4lJnRgm_is/s1600/DFG_2014-09-23-23-03-06.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8nCI8NkLyOjMfopasce-jPw9tKSh7ndM3QK7q28K0jxzzmRvosMd-IOWBBSj4ided-bpNK6Hzm1nhjaxt6miype19epSS-URhIN30UhH90jk0q_rqDcPfzWIU53MnarmTH4lJnRgm_is/s1600/DFG_2014-09-23-23-03-06.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Search for list item&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&amp;nbsp;Code Explained:&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Our main goal in this activity is to group an image and text in the same list area. To do this our normal ArrayAdapter will not do as it only contains only in type of object . So in our Custom Adapter (which basically extends ArrayAdapter to get the text data) we create a new class ViewHolder to encapsulate image &amp;amp; text. MyCustomAdapter class has a constructor which receives the list of sites in our case, and store it in a local variable.&lt;/li&gt;
&lt;li&gt;If the getView() method is not there in your class add it by -&amp;gt; Right-click &amp;gt; Source &amp;gt; Override/implement Methods.&lt;/li&gt;
&lt;li&gt;Now in the getView() method we first create a View object &#39;myview&#39; and set it to convertView. This is basically an optimization step using which we save the inflating of the view on very redraw (or scroll ) of the list. If initially convertView is null (which it will be), a new layout inflator is inflated and attached to our view using the setTag() method.&lt;/li&gt;
&lt;li&gt;After this the string from the local variable is added to our viewHolder using &amp;lt;Holder name&amp;gt;.&amp;lt;Text Object&amp;gt;.setText(String).&lt;/li&gt;
&lt;li&gt;Then the corresponding images are loaded from the res/drawable-hdpi folder.&lt;/li&gt;
&lt;li&gt;Now in the main activity we create an object of MyCustomAdapter , sending it the String[], and setting it to our ListView.&lt;/li&gt;
&lt;li&gt;getActionBar().hide() is used in onCreate() to hide the action bar at the top so as to get more screen space (Requires &amp;nbsp;android:minSdkVersion=&quot;11&quot; in AndroidManifest.xml).&lt;/li&gt;
&lt;li&gt;Also a Vibrator object is created in onListItemClick() to make the device vibrate on item click.To be able to use this service do the following:&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;import android.os.Vibrator;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;In the AndroidManifest.xml file add&amp;nbsp;&lt;/li&gt;
&amp;lt;uses-permission android:name=&quot;android.permission.VIBRATE&quot;/&amp;gt;&lt;/ol&gt;
&lt;/ol&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Download Code:&lt;/span&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/we1v9h4dfgaod0r/AAAIvsYgRkmdXZfe530F_GEma?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiAaJk3Kf9CcZNWJvXuT3FRyEBNGAklEuBGWf0Ve81Uwk_fQ8-DOJbPihzhnXheX8yFiLT9dQtsWgcnVzVtMJWPr-ko1a6kyUU6uMpAGUvlifq5Jdr1fCTuK6L2UYhjgH-Gg_PiPmTzmu0/s1600/unnamed.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/09/android-listview-part-iii.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsHkuRwPyxES9KVhjelf6uLv8EnppUzgZdswqbbz4v3W87uc4oIFq2wChfYlVmwgY3b_T6eGtzI9woz357xUn6MbWt9ukDJz8w1Q_I2sXQCYow-gHbKyQrbRLYA6oQobNZIIuLFri7Q3k/s72-c/Android+List+view+part+3.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-509132482705483950</guid><pubDate>Sun, 21 Sep 2014 15:28:00 +0000</pubDate><atom:updated>2014-09-27T13:05:17.209-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Basics</category><category domain="http://www.blogger.com/atom/ns#">Android List View Part 2</category><category domain="http://www.blogger.com/atom/ns#">array adapter</category><category domain="http://www.blogger.com/atom/ns#">list adapter</category><category domain="http://www.blogger.com/atom/ns#">setListAdapter</category><title>Android ListView Part II</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuONEQrsSg_DJWdNUURWNGfdOLvWE84cEtgqN4-Gwycmp7Z7xfuWtHaT9LP8gSUN5HdRa9vMlPDgc1GhRrthoT-3YT6nYfFXQi0t6o_KdUua0uMb0BtgexcDfLgHLc1-pr_eV51EjJQVk/s1600/Android+List+view+part+2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuONEQrsSg_DJWdNUURWNGfdOLvWE84cEtgqN4-Gwycmp7Z7xfuWtHaT9LP8gSUN5HdRa9vMlPDgc1GhRrthoT-3YT6nYfFXQi0t6o_KdUua0uMb0BtgexcDfLgHLc1-pr_eV51EjJQVk/s1600/Android+List+view+part+2.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Welcome again to Android ListView. What we are gonna do is build up on the progress of Part I, and add some new concepts such as Intents and SearchManager to it. So let&#39;s begin:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp;1. &amp;nbsp;Create a new Android Application Project&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Follow up on Part I for the basic app setup process or create new by going to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVgMFWmoO7iogeK3fBjYXcAJZhBv8-jJ__zH2O4sVvWEolTbNohdroHQ9qBw8OMi2GQLCFHy2yr1R_MW0EmnhzA6CpLl-hvwCZxOUbYpOFF5l5HGnypqvYpxBhjDQSze23sRShF6rZSrk/s1600/app_name.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVgMFWmoO7iogeK3fBjYXcAJZhBv8-jJ__zH2O4sVvWEolTbNohdroHQ9qBw8OMi2GQLCFHy2yr1R_MW0EmnhzA6CpLl-hvwCZxOUbYpOFF5l5HGnypqvYpxBhjDQSze23sRShF6rZSrk/s1600/app_name.PNG&quot; height=&quot;338&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;New Android Appication&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;2. &amp;nbsp;Add List View to activity_main.xml&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Add the ListView to the graphical layout of the app from the Palette by dragging and dropping from the Composite Section.&lt;/li&gt;
&lt;li&gt;Remember to set the android:id to &quot;@andorid:id/list&quot;.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHQVS-Lex_pNvhaer2fGlius8kg_Uc07WeIcxCwxedhxLVCKjeM2IaVoeiWFlY4Wv6U8_xpZQULYwLlh021JWtWDk6f__7BPn0rj4F_bX-iyahzwBl0tpnw0c2DrNhlmR_gEMr6f4cvuM/s1600/list&amp;intent+xml.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHQVS-Lex_pNvhaer2fGlius8kg_Uc07WeIcxCwxedhxLVCKjeM2IaVoeiWFlY4Wv6U8_xpZQULYwLlh021JWtWDk6f__7BPn0rj4F_bX-iyahzwBl0tpnw0c2DrNhlmR_gEMr6f4cvuM/s1600/list&amp;intent+xml.PNG&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Empty ListView&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/dc02ebf3c442ae4f6fdc.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;3. &amp;nbsp;Code away the MainActivity.java&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Add the code below to your MainActivity.java.&lt;/li&gt;
&lt;li&gt;For code explanation scroll to the end of the post.&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/fea3aec1e333e8447d01.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;4. Run the app&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Launch the app in an AVD or on a physical device by pressing CTRL&amp;nbsp;+&amp;nbsp;F11.&lt;/li&gt;
&lt;/ul&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5blsxvGMr53-3osWCD2r7pY1EEdER2rsfNP-bdqUOdaAjsnRqCcyEpa8Ib8ooJFbXJyReWAYVFNK8DJ_fcchwpucyMnAs5SM6rr-tr3mU7CEc_nSjxjeBtdbCCmGKxIz_SqN5zpCrVHg/s1600/DFG_2014-09-21-20-32-21.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg5blsxvGMr53-3osWCD2r7pY1EEdER2rsfNP-bdqUOdaAjsnRqCcyEpa8Ib8ooJFbXJyReWAYVFNK8DJ_fcchwpucyMnAs5SM6rr-tr3mU7CEc_nSjxjeBtdbCCmGKxIz_SqN5zpCrVHg/s1600/DFG_2014-09-21-20-32-21.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Main Screen&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDGj34F9UjzG3oGKVymtl-I9I1L3tc3K64HCj0aQMOnBKxSm9Thqr4SJLFk1Y8FofSMhGCASW4i8MGXimqPYL0O5IVduboiKEt6hWMNuql5GnBGZKeTxIg1ketsCqtjmFUTm-qJREQZWw/s1600/DFG_2014-09-21-20-35-36.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiDGj34F9UjzG3oGKVymtl-I9I1L3tc3K64HCj0aQMOnBKxSm9Thqr4SJLFk1Y8FofSMhGCASW4i8MGXimqPYL0O5IVduboiKEt6hWMNuql5GnBGZKeTxIg1ketsCqtjmFUTm-qJREQZWw/s1600/DFG_2014-09-21-20-35-36.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Search Results&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: #4c1130;&quot;&gt;Code&amp;nbsp;Explained:&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The java code in this tutorial builds up on the ListView Part I. The new thing here is that this app now can search the name in the list item clicked onto the Internet.&lt;/li&gt;
&lt;li&gt;This is accomplished by adding an &lt;u&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;Intent&lt;/span&gt;&lt;/u&gt; to the app. Intents are used to describe run time actions to be done by the app. Through Intents we can call any other activity or perform any default actions provided by the system (e.g,&amp;nbsp;&lt;span style=&quot;background-color: #6fa8dc;&quot;&gt;Intent.ACTION_WEB_SEARCH&lt;/span&gt;).&lt;/li&gt;
&lt;li&gt;We add this Intent in the onListItemClick() method of the ListActivity which is called when any list item is selected by clicking touching.&lt;/li&gt;
&lt;li&gt;Another new thing here are the Toasts. A &lt;span style=&quot;color: #0b5394;&quot;&gt;&lt;u&gt;Toast&lt;/u&gt; &lt;/span&gt;is like a real toast which pops up to notify you about your choices or any thing else. The function Toast.makeText( Context, String, Length).show() is used to display Toasts.&lt;/li&gt;
&lt;li&gt;Now we make a search string, put it in the Extras field of our intent under the &lt;span style=&quot;background-color: #6fa8dc;&quot;&gt;SearchManager.Query name&lt;/span&gt;. Its similar to a name:value pair.&lt;/li&gt;
&lt;li&gt;Finally we start the intent by calling startActivity(my_intent).&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;&lt;span style=&quot;color: #4c1130;&quot;&gt;Download Code:&lt;/span&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/l4yu2zlhyjh96r7/AACf9nvHQrIvjAR1BvhK_NHsa?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheL8pHZo2Th4Rb5IvjzHdFpj5S2Pqs2G_X6vYfxF62qZCCvunLVOh7ElPXLRw9-PPBNh9oOM7m1hJ70UedrNbl6T2SzyujjetWhhAvs2wHj2nl-AAMduHpWptTnYAm1d3npQCr7S9v2iI/s1600/unnamed.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://roadtodroid.blogspot.com/2014/09/welcome-again-to-android-listview.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuONEQrsSg_DJWdNUURWNGfdOLvWE84cEtgqN4-Gwycmp7Z7xfuWtHaT9LP8gSUN5HdRa9vMlPDgc1GhRrthoT-3YT6nYfFXQi0t6o_KdUua0uMb0BtgexcDfLgHLc1-pr_eV51EjJQVk/s72-c/Android+List+view+part+2.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-6996957318582720049</guid><pubDate>Sun, 21 Sep 2014 07:28:00 +0000</pubDate><atom:updated>2014-09-27T13:06:36.824-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Basics</category><category domain="http://www.blogger.com/atom/ns#">Android List view Part 1</category><category domain="http://www.blogger.com/atom/ns#">array adapter</category><category domain="http://www.blogger.com/atom/ns#">list adapter</category><category domain="http://www.blogger.com/atom/ns#">setListAdapter</category><title>Android ListView Part I</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOSqA0yfZEHbgW4VOuTMd20GXVd1ReXADT6VU0pmrdo2zue_oZM5tof0W4dVuP9ztHu0JKFNiKcKTkzOo9L-STUlbUP6vqc6lp9wmsTxYNMYCrBHoGPwvxeRyUiP_p0bZ5THnbPViDiE4/s1600/Andorid+List+View+part+1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOSqA0yfZEHbgW4VOuTMd20GXVd1ReXADT6VU0pmrdo2zue_oZM5tof0W4dVuP9ztHu0JKFNiKcKTkzOo9L-STUlbUP6vqc6lp9wmsTxYNMYCrBHoGPwvxeRyUiP_p0bZ5THnbPViDiE4/s1600/Andorid+List+View+part+1.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
List Views are the most versatile of the widgets in Android as they can be used in many ways and customized according to need.List Views are used to list various options to the user or to show what&#39;s already there with the system and update it with time to time.Let&#39;s have a closer look at List Views.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Be patient and follow the road:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;1. Create a new Android Application Project&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;li&gt;Provide a name for the app and proceed as shown in previous blogs.&lt;/li&gt;
&lt;li&gt;Select Empty Activity under the activity type.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfhusbUOJJdpvxbCqawNVPGwnt_PeliDlIubh2hSz1txLUr3TRu_QPw7FxDwHZiuzsQBvf9IUZ9-zNs6uEBfq8Aj7CXnn9dwOY5VBE7V2sehHXZtXsmsyfQI_700Mnh4SsL07j5PzDiC8/s1600/app_name.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfhusbUOJJdpvxbCqawNVPGwnt_PeliDlIubh2hSz1txLUr3TRu_QPw7FxDwHZiuzsQBvf9IUZ9-zNs6uEBfq8Aj7CXnn9dwOY5VBE7V2sehHXZtXsmsyfQI_700Mnh4SsL07j5PzDiC8/s1600/app_name.PNG&quot; height=&quot;338&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Naming the app&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;2. &amp;nbsp;Add a list view to activity_main.xml&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Remove the Text View from the graphical layout saying Hello World.&lt;/li&gt;
&lt;li&gt;In the Palette go to Composite &amp;gt; ListView.&lt;/li&gt;
&lt;li&gt;Drag and drop the list view to the graphical window.&lt;/li&gt;
&lt;li&gt;Re-size it accordingly.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2CFTZXnptLPHEJ322Z0CSc0RD1VcUYePySsiI0eFyRFOsjv5UDaB7EXvqMUh8w5_Vcf6nGUkGUJFqagHCsp3KkwLEkzZpc-3mtgKE2nbjg22ajqdUUsEhMapVpLn0RAH_vi0IeS4U4T4/s1600/listview.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2CFTZXnptLPHEJ322Z0CSc0RD1VcUYePySsiI0eFyRFOsjv5UDaB7EXvqMUh8w5_Vcf6nGUkGUJFqagHCsp3KkwLEkzZpc-3mtgKE2nbjg22ajqdUUsEhMapVpLn0RAH_vi0IeS4U4T4/s1600/listview.PNG&quot; height=&quot;400&quot; width=&quot;232&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Empty ListView&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
3. &amp;nbsp;Make some changes to activity_main.xml&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Firstly change the background color of your relative layout to black(#000000), as shown in code below.&lt;/li&gt;
&lt;li&gt;Secondly change the id of the ListView to &quot;@andorid:id/list&quot;.&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/aaf482aeb37cc2c3ec9a.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
4. Open the MainActivity.java file&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open the MainActivity,java file from src folder in the package explorer.&lt;/li&gt;
&lt;li&gt;Add the code shown below. Remember to change the package name.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/9aa5e870ffd1fb22536d.js&quot;&gt;&lt;/script&gt;

&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
5. Run the app&lt;/h2&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Run the app on a AVD or a physical device as demonstrated in previous blogs.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh4_WwI4ERAT-dSz2bUeGb6wJZPkzo21Iuibmrzy8QIpTm7AkmBIEd0c6k8nchcPjikHQzS4HTVaV4pcEtU6fS0JRLyP_27_YYmGIKtwPLMftT6fbYz6gPoU2rG20_4_rJc4xCXK9ShF8/s1600/runad.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh4_WwI4ERAT-dSz2bUeGb6wJZPkzo21Iuibmrzy8QIpTm7AkmBIEd0c6k8nchcPjikHQzS4HTVaV4pcEtU6fS0JRLyP_27_YYmGIKtwPLMftT6fbYz6gPoU2rG20_4_rJc4xCXK9ShF8/s1600/runad.PNG&quot; height=&quot;400&quot; width=&quot;247&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Run As Android Application&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3lKCkl9VU8ucik7xI5qZHiYYiI40sHiYconsDtc39AhnUcz2Va-OvPTlRM-_e_eHq5kl8zX_NZf-repPhRSwZZSEk3acaJ6rLNF_hmuLTyW03Rz6hyphenhyphenBMdjSU5kjKQWU4gfd4-BQ5mARU/s1600/DFG_2014-09-21-12-35-28.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj3lKCkl9VU8ucik7xI5qZHiYYiI40sHiYconsDtc39AhnUcz2Va-OvPTlRM-_e_eHq5kl8zX_NZf-repPhRSwZZSEk3acaJ6rLNF_hmuLTyW03Rz6hyphenhyphenBMdjSU5kjKQWU4gfd4-BQ5mARU/s1600/DFG_2014-09-21-12-35-28.png&quot; height=&quot;400&quot; width=&quot;237&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;ListView app&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Code Explained:&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The MainActivity class of the app extends a ListActivity.&amp;nbsp;ListActivity has a default layout that consists of a single, full-screen list in the center of the screen. &lt;/li&gt;
&lt;li&gt;We create a private ArrayAdapter to bind the data to the List View using a ListAdapter interface.&lt;/li&gt;
&lt;li&gt;The function show_in_list() declares a List object containing names of movies.&lt;/li&gt;
&lt;li&gt;.add(String ) is used to add Strings to the arrayadapter.&lt;/li&gt;
&lt;li&gt;Finally in onCreate we set the data in the list using the setListAdapter(arrayadapter) function.&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;Download Code:&lt;/span&gt;&lt;/h2&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/j7st7q63yzhyeht/AACol0s1WrCON6XNFLEXKIVGa?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheL8pHZo2Th4Rb5IvjzHdFpj5S2Pqs2G_X6vYfxF62qZCCvunLVOh7ElPXLRw9-PPBNh9oOM7m1hJ70UedrNbl6T2SzyujjetWhhAvs2wHj2nl-AAMduHpWptTnYAm1d3npQCr7S9v2iI/s1600/unnamed.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://roadtodroid.blogspot.com/2014/09/android-listview-part1.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOSqA0yfZEHbgW4VOuTMd20GXVd1ReXADT6VU0pmrdo2zue_oZM5tof0W4dVuP9ztHu0JKFNiKcKTkzOo9L-STUlbUP6vqc6lp9wmsTxYNMYCrBHoGPwvxeRyUiP_p0bZ5THnbPViDiE4/s72-c/Andorid+List+View+part+1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-7574469130357748393</guid><pubDate>Fri, 19 Sep 2014 19:18:00 +0000</pubDate><atom:updated>2014-09-27T13:07:53.100-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Basics</category><category domain="http://www.blogger.com/atom/ns#">Button</category><category domain="http://www.blogger.com/atom/ns#">TextView</category><title>Android Buttons and TextViews</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1J5EBxQ3Yk4Ynnh79IqBXNoUET_lO4SCus5wcXhSwp7Reed3SOSz-_XgEcbhPvUkYKbz6KlE7xVm83pXPWN8sj4tuhxnXAZdUUCFVSFOQoH_VrbPyUlekj7Njnc1gppTZXaoRSjfT-2M/s1600/card+title1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1J5EBxQ3Yk4Ynnh79IqBXNoUET_lO4SCus5wcXhSwp7Reed3SOSz-_XgEcbhPvUkYKbz6KlE7xVm83pXPWN8sj4tuhxnXAZdUUCFVSFOQoH_VrbPyUlekj7Njnc1gppTZXaoRSjfT-2M/s1600/card+title1.png&quot; height=&quot;360&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
After testing the basic environment of the Android SDK , its time to start fiddling around with some cool user interactions provided by Android.&lt;br /&gt;
In this post I will demonstrate using Android widgets such as Buttons and TextViews.&lt;br /&gt;
&lt;br /&gt;
Just be patient and follow the steps below:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;1. Create a new Android Application Project&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;li&gt;Give a name to your app and proceed forward as in the last post (First App).&lt;/li&gt;
&lt;li&gt;Remember to select an Empty Activity in activity type.&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjkQ1RuWuguNRyE6FkOgW757d1BdB4mxOlaMn3ihF0qmWx0mCEL46KFO87wcHLkd5MUALyCMiHtn1OrMBIYbDyY9Yl2NOmL-iC40cxRRo7q5vc0zCovdanNsYpEM7HibB_41kTxB2FkRo/s1600/app+name.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjjkQ1RuWuguNRyE6FkOgW757d1BdB4mxOlaMn3ihF0qmWx0mCEL46KFO87wcHLkd5MUALyCMiHtn1OrMBIYbDyY9Yl2NOmL-iC40cxRRo7q5vc0zCovdanNsYpEM7HibB_41kTxB2FkRo/s1600/app+name.PNG&quot; height=&quot;341&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Naming the app&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2&gt;
&amp;nbsp;2. &amp;nbsp;Open the activity_main.xml file&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Open the activity_main.xml file from the Package Explorer , if not already open.&lt;/li&gt;
&lt;li&gt;This file is located res &amp;gt; layout folder under your project in Package Explorer.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGcKY8LbMK-BaWsxV3OUOiyfIyNQtat6S25dGiiEO0XrdZV7zuhl_3kbVEgIBth-EGzA0U4V2Vhwp2ylmMc1AAuGyC1lWjHhNOz3fy_y8SjCzsSgldplb1EjyWF3Of4P2S5moAi5ZXQIQ/s1600/Package+explorer.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGcKY8LbMK-BaWsxV3OUOiyfIyNQtat6S25dGiiEO0XrdZV7zuhl_3kbVEgIBth-EGzA0U4V2Vhwp2ylmMc1AAuGyC1lWjHhNOz3fy_y8SjCzsSgldplb1EjyWF3Of4P2S5moAi5ZXQIQ/s1600/Package+explorer.PNG&quot; height=&quot;400&quot; width=&quot;182&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Package Explorer&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;h2&gt;
&amp;nbsp;3. &amp;nbsp;Add Button and TextView&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Remove the TextView showing &quot;Hello World&quot; by selecting it and pressing Delete.&lt;/li&gt;
&lt;li&gt;Now in the Palette click on From Widgets tab and drag and drop a button to the Graphical Layout.&lt;/li&gt;
&lt;li&gt;Re-size and re-position it any way you like.&lt;/li&gt;
&lt;li&gt;Similarly drag and drop a TextView (Large Text or any other) to the Graphical Layout.&lt;/li&gt;
&lt;li&gt;You can tinker around with the self generated xml code by clicking on the activity_main.xml tab at the bottom of the eclipse window.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEs3JnrrBnqiOJ6rfM4VsuRQpVeS2jD3qto2Iz0n7zMxXpuaQz_QEcHY4buhpdbkOntWmr1bod7KPqCkztGmqtWh2JPC6-NTAnUVsuKfeP_JVuuJG_ztZ6Pe0rfCXMXBlG0hyiCE5ZZz0/s1600/layout.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEs3JnrrBnqiOJ6rfM4VsuRQpVeS2jD3qto2Iz0n7zMxXpuaQz_QEcHY4buhpdbkOntWmr1bod7KPqCkztGmqtWh2JPC6-NTAnUVsuKfeP_JVuuJG_ztZ6Pe0rfCXMXBlG0hyiCE5ZZz0/s1600/layout.PNG&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Final Layout&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/4fc577b76aa0f1933178.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;4. Open the MainActivity.java file&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;If not already open, go to Package Explorer and under your project go to src &amp;gt; (Package Name) &amp;gt; MainActivity.java.&lt;/li&gt;
&lt;li&gt;Copy the java code below to your MainActivity.java (Remember to change the package name to your &amp;nbsp;package name).&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;script src=&quot;https://gist.github.com/shobhitchittora/baebd63bc4afffc730d2.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;5. &amp;nbsp;Run the Application&lt;/h2&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Build and run the app by pressing CTRL&amp;nbsp;+ F11 or click Run &amp;gt; Run.&lt;/li&gt;
&lt;li&gt;Remember to configure AVD as shown in previous post or connect your own device to install and run the app.&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlDJaCmnZlTexPi3F8MBKiUwI7A_JaaoB4KmmA8BQIseMjmmVxBjwRPVbCgrjWE_gE79426qBW_sNMTwPFSvuUz8Ot7Q2pYUzGIwsnO7s3EN8HOf4N-WYTM3K_eoApCPRWzbm1Rz-v-OA/s1600/DFG_2014-09-20-11-21-40.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlDJaCmnZlTexPi3F8MBKiUwI7A_JaaoB4KmmA8BQIseMjmmVxBjwRPVbCgrjWE_gE79426qBW_sNMTwPFSvuUz8Ot7Q2pYUzGIwsnO7s3EN8HOf4N-WYTM3K_eoApCPRWzbm1Rz-v-OA/s1600/DFG_2014-09-20-11-21-40.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Launch Screen&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFxVeEOCDM1HesYtRxYz7CoqFiIiF1z9pybv1-XWW6KGZeXV0sFfmJkoL83xkj7drO8QtS4ILVDcOKh75xj7M7twguQxhXwQ0A-WSbzWJPFfP4gmH6_Uy4ISJ8rENOWG8R9FvcMgx7cvg/s1600/DFG_2014-09-20-11-26-41.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgFxVeEOCDM1HesYtRxYz7CoqFiIiF1z9pybv1-XWW6KGZeXV0sFfmJkoL83xkj7drO8QtS4ILVDcOKh75xj7M7twguQxhXwQ0A-WSbzWJPFfP4gmH6_Uy4ISJ8rENOWG8R9FvcMgx7cvg/s1600/DFG_2014-09-20-11-26-41.png&quot; height=&quot;400&quot; width=&quot;238&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;On Button Click&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
&amp;nbsp; &lt;span style=&quot;color: #4c1130;&quot;&gt;Code Explained:&lt;/span&gt;&lt;/h2&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;The first few lines of the code has some import statements which are auto included or can be included by clicking on error suggestions popups on the left of the code window.&lt;/li&gt;
&lt;li&gt;Our main activity is that class which has the main GUI thread. Its the first screen which the user sees when the app is launched. In this example, the main activity extends ActionBarActivity to suggest that it shows an action bar on the top of the app with and methods OnCreateOptionsMenu creates the list icon on the right of the action bar.&lt;/li&gt;
&lt;li&gt;In out MainActivity class we create two private variables my_button &amp;amp; my_textView to point &amp;nbsp;out button and textview in our xml file (activity_main).&lt;/li&gt;
&lt;li&gt;The method OnCreate is called when the Android system wants to draw something related to the app on the main screen.&lt;/li&gt;
&lt;li&gt;The OnCreate method first sets the view of the app to activity_main.xml by callins setContentView(R.layout.activity_main);&lt;/li&gt;
&lt;li&gt;The we bind our variables my_button &amp;amp; my_textView to corresponding id&#39;s in main xml file.&lt;/li&gt;
&lt;/ol&gt;
Note: The R.java file is a self updating file which the SDK maintains to collect all the resources and properties of the app at one place. Do not try to edit it at any time , as there may be consequences!&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; 7. Next we bind a event listener to our button which is called when the user clicks it.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; 8. Here we set the text of the TextView to whatever we want.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&amp;nbsp;Download Code:&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://www.dropbox.com/sh/x81ugu9nibm2a3t/AADJSdWAK1XUfbNiqDoS9cDSa?dl=1&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEheL8pHZo2Th4Rb5IvjzHdFpj5S2Pqs2G_X6vYfxF62qZCCvunLVOh7ElPXLRw9-PPBNh9oOM7m1hJ70UedrNbl6T2SzyujjetWhhAvs2wHj2nl-AAMduHpWptTnYAm1d3npQCr7S9v2iI/s1600/unnamed.png&quot; height=&quot;200&quot; width=&quot;200&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #4c1130;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</description><link>http://roadtodroid.blogspot.com/2014/09/android-buttons-and-textviews.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1J5EBxQ3Yk4Ynnh79IqBXNoUET_lO4SCus5wcXhSwp7Reed3SOSz-_XgEcbhPvUkYKbz6KlE7xVm83pXPWN8sj4tuhxnXAZdUUCFVSFOQoH_VrbPyUlekj7Njnc1gppTZXaoRSjfT-2M/s72-c/card+title1.png" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4560389092782236816.post-1759001033359570537</guid><pubDate>Fri, 19 Sep 2014 14:52:00 +0000</pubDate><atom:updated>2014-09-24T06:04:05.669-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android Basics</category><category domain="http://www.blogger.com/atom/ns#">AVD</category><category domain="http://www.blogger.com/atom/ns#">First App</category><category domain="http://www.blogger.com/atom/ns#">google</category><category domain="http://www.blogger.com/atom/ns#">Hello World</category><category domain="http://www.blogger.com/atom/ns#">IDE</category><category domain="http://www.blogger.com/atom/ns#">Install Eclipse</category><category domain="http://www.blogger.com/atom/ns#">Install JDK</category><category domain="http://www.blogger.com/atom/ns#">launch app</category><category domain="http://www.blogger.com/atom/ns#">SDK Updates</category><title>Android SDK Setup and First App</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Let’s start with setting up with the development environment for Android app development and make our first “Hello World” app.&lt;br /&gt;
&lt;div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;1. &amp;nbsp;Download and Install Eclipse IDE&lt;/h2&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Download the Android SDK from &lt;a href=&quot;https://developer.android.com/sdk/index.html&quot;&gt;https://developer.android.com/sdk/index.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
Note: Many of you might know that Android Studio , which is currently in its Beta, is going to be the official IDE for Android .But nonetheless I am going to demonstrate setting up Eclipse ADT bundle. &lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Extract the zip file.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
&lt;/h2&gt;
&lt;h2&gt;
&amp;nbsp;2. &amp;nbsp; Download and Install JDK and Java SE Platform&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;Download and Install JDK from &lt;a href=&quot;http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html&quot;&gt;http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Download and install Java SE from &lt;a href=&quot;http://www.oracle.com/technetwork/java/javase/downloads/index.html&quot;&gt;http://www.oracle.com/technetwork/java/javase/downloads/index.html&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;/h2&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;3. &amp;nbsp; Start Eclipse&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to the directory where you have unzipped the adt bundle and then go to eclipse folder and start eclipse.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;4. &amp;nbsp; Install any updates from the SDK manager  (may skip this &amp;nbsp; &amp;nbsp;at first)&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;In eclipse go to Window &amp;gt; Android SDK Manger.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Check and install any update for the environment you want.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIZEzTMo7Twoq7upWEYOcQ76cd1f0ZdeOLXQVldBsd5fiGiMR_LA1GW4BFy1wDMk3AaxJ_VDFup5bYmZ_oe0PN_OktTizIDB-ftjZf8icIFU8F6vBipoXArucqxtVHUzDW31wkslqrwYA/s1600/sdk+manager.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIZEzTMo7Twoq7upWEYOcQ76cd1f0ZdeOLXQVldBsd5fiGiMR_LA1GW4BFy1wDMk3AaxJ_VDFup5bYmZ_oe0PN_OktTizIDB-ftjZf8icIFU8F6vBipoXArucqxtVHUzDW31wkslqrwYA/s1600/sdk+manager.PNG&quot; height=&quot;385&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;SDK Manager&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;5. &amp;nbsp;Create your first Android App&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Go to File &amp;gt; New &amp;gt; Android Application Project.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Enter your Application’s Name (Remember the first letter of the name must be capital).&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Select Minimum supported SDK for your app and also the Target SDK&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Select a theme if you want.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Click Next.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibaC1S8lQfKBb6mw0ol4UYzbHdhnxSFxc58DwjFLXKrLUYk8iH0vGkXG-UVHSj7Sqma0kp6EuUhKMWgkOjNOFiEGKneLlrvTC2L3kNrO67DosYs994NqWRPcRk1BJ-ouFOibs1kyQ7UhE/s1600/new+project.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibaC1S8lQfKBb6mw0ol4UYzbHdhnxSFxc58DwjFLXKrLUYk8iH0vGkXG-UVHSj7Sqma0kp6EuUhKMWgkOjNOFiEGKneLlrvTC2L3kNrO67DosYs994NqWRPcRk1BJ-ouFOibs1kyQ7UhE/s1600/new+project.PNG&quot; height=&quot;343&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;New Andriod Applicatoin&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;6. &amp;nbsp; Select a path to store the project&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Select a custom path, if you want for your app.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;Click Next.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZrNdZq-swUOr_3ipJRwCk1z2gZcvcfAgz3koHEBa0nI79USQVSixZ_5K8J6b-xhE0L8KPCt1Rs558ztjG27-odJ1C6nY7lCFicRF4VfIt3Z-Y2VZkxQXSoTns85XvDPzVXrZNAfPTLeY/s1600/icon+page.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZrNdZq-swUOr_3ipJRwCk1z2gZcvcfAgz3koHEBa0nI79USQVSixZ_5K8J6b-xhE0L8KPCt1Rs558ztjG27-odJ1C6nY7lCFicRF4VfIt3Z-Y2VZkxQXSoTns85XvDPzVXrZNAfPTLeY/s1600/icon+page.PNG&quot; height=&quot;340&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;App Configuration&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;7. &amp;nbsp;Select an Icon for the app&lt;/h2&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;You may want to select your own icon in this dialog box or use the default one.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Other icon properties can also be fiddled with.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;When you are done click Next.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQTQfzb72vOiJAVRtBECXEk7_zHoxtR5c_xbVomRm17ejrkrEkeZoK9GrDARgvwaA_fv3LYd8oygNRQ8g9XCNanb87kQYZpSIoo4yPplY8TFq2zD30i1Jj1tnmzmjyptTX7LgP8lwMBws/s1600/icon+page+2.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQTQfzb72vOiJAVRtBECXEk7_zHoxtR5c_xbVomRm17ejrkrEkeZoK9GrDARgvwaA_fv3LYd8oygNRQ8g9XCNanb87kQYZpSIoo4yPplY8TFq2zD30i1Jj1tnmzmjyptTX7LgP8lwMBws/s1600/icon+page+2.PNG&quot; height=&quot;357&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Select an Icon&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;8. &amp;nbsp;Select an Activity type&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Select an activity type such as blank, empty and others.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;For now select an Empty Activity.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Click Next.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;





&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlOSwAud3lktf0jW4mFjBZn3p6ZXoYoNJ_ve-rD2cX9Rdv7yZ8zG_ZCkl9mMPGBeLape08bvOWLksax6SFtdJqNCihnnEsBN0m1Byv_tfPJyryVUpveX3Vkf8Bz_ZI5TXQ7JyFU4XCXhs/s1600/activity+page.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlOSwAud3lktf0jW4mFjBZn3p6ZXoYoNJ_ve-rD2cX9Rdv7yZ8zG_ZCkl9mMPGBeLape08bvOWLksax6SFtdJqNCihnnEsBN0m1Byv_tfPJyryVUpveX3Vkf8Bz_ZI5TXQ7JyFU4XCXhs/s1600/activity+page.PNG&quot; height=&quot;358&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Select Activity Type&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h2&gt;
&amp;nbsp;9. &amp;nbsp;Choose a name for the Main Activity&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Give a name you like to the main activity for the app.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Click Finish.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;



&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh83hGVJK_sd6ls_2A6hESq2PLmC3gNcZygG4JGR_ztMXtdev6jrL49UyhJByGF5F9HMXb7Kdm-eMeJ_CUZSVUCf2OnJRAWoo9aD9xw1Lr57SQMJd7o05BG_uLe-dnOkbvK2PUAwjRW7Eo/s1600/main+activty.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh83hGVJK_sd6ls_2A6hESq2PLmC3gNcZygG4JGR_ztMXtdev6jrL49UyhJByGF5F9HMXb7Kdm-eMeJ_CUZSVUCf2OnJRAWoo9aD9xw1Lr57SQMJd7o05BG_uLe-dnOkbvK2PUAwjRW7Eo/s1600/main+activty.PNG&quot; height=&quot;357&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Activity Name&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;10. &amp;nbsp;Launch your first app&lt;/h2&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;To launch your first app you can either use your physical android device via USB or use the emulator provided by the SDK.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;To run the app on physical device just connect the device and make sure that all its drives are installed correctly. Then press CTRL + F11 and select run as an Android Application.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;To run on an emulator setup an AVD (Android Virtual Device) by going to Window &amp;gt; Android Virtual Device Manger. Then click on Create and fill in the dialog box for the properties on the AVD. Now select the AVD and click on Start. And to run the app press CTRL + F11.&lt;/li&gt;
&lt;/ul&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;If there are no errors (which won’t be the case), then the app will launch either on the device you connected or on an AVD.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;







&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;margin-left: 108.0pt; mso-add-space: auto; mso-list: l0 level1 lfo2; text-indent: -18.0pt;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;





&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 36.0pt;&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span lang=&quot;EN-US&quot;&gt;&amp;nbsp;&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoDTPN6pPKx2nfl7aev5tsTNHY48zIQLuFX042fRGUtoKBftX_FB_QCzEjVeqTfF7ozjsHDCwrFp524Lbd34neylmepRO60x7aclEnmQEnxw8YMualXnwdMcCMYPFNF7OpCKqnn58ml5w/s1600/Capture.PNG&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoDTPN6pPKx2nfl7aev5tsTNHY48zIQLuFX042fRGUtoKBftX_FB_QCzEjVeqTfF7ozjsHDCwrFp524Lbd34neylmepRO60x7aclEnmQEnxw8YMualXnwdMcCMYPFNF7OpCKqnn58ml5w/s1600/Capture.PNG&quot; height=&quot;400&quot; width=&quot;237&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;App Preview&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;/span&gt;&lt;/h2&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://roadtodroid.blogspot.com/2014/09/lets-start-with-setting-up-with.html</link><author>noreply@blogger.com (Anonymous)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIZEzTMo7Twoq7upWEYOcQ76cd1f0ZdeOLXQVldBsd5fiGiMR_LA1GW4BFy1wDMk3AaxJ_VDFup5bYmZ_oe0PN_OktTizIDB-ftjZf8icIFU8F6vBipoXArucqxtVHUzDW31wkslqrwYA/s72-c/sdk+manager.PNG" height="72" width="72"/><thr:total>0</thr:total></item></channel></rss>