<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='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'><id>tag:blogger.com,1999:blog-512998992927617317</id><updated>2026-10-12T00:52:16.187-07:00</updated><category term="Android"/><category term="WebView"/><category term="Cookies"/><category term="SD Card"/><category term="User Interface"/><category term="APK"/><category term="Activity"/><category term="Capabilities"/><category term="Javascript"/><category term="Limitations"/><category term="Permanent"/><category term="RAM"/><category term="Settings"/><category term="Synchronization"/><category term="UI"/><category term="URL"/><category term="UserInterface"/><category term="WebKit"/><category term="Window Management"/><category term="accessing"/><category term="application"/><category term="customize"/><category term="files"/><category term="handling"/><category term="how to"/><category term="images"/><category term="injecting"/><category term="intent"/><category term="intercepting"/><category term="launcher"/><category term="override"/><category term="screen density"/><category term="shortcuts"/><category term="sync"/><title type='text'>Android</title><subtitle type='html'>Blog is for educating users about android programming and troubleshooting.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-512998992927617317.post-8669093079737711659</id><published>2011-06-12T22:53:00.001-07:00</published><updated>2011-06-16T20:56:25.631-07:00</updated><title type='text'>Handling Screen Orientation - Part 2</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;How to handle rotation?&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Now if you choose to rotate your activity with display either specifying “rotate as sensor” or using “orientation setting” you must handle the steps that are taken when the display is rotated.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Whenever the window rotates, your activity is destroyed and recreated, and “onCreate(Bundle)” is executed again.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;You may need to save the activity state before this happens. To achieve that you can override the&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt; onSaveInstanceState(Bundle outState)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;For Example: You may want to save the Value of a String array before screen orientation change restarts your activity.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;To do this override the onSaveInstanceState method of Activity class like this:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public class&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; SampleActivity &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;extends&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; Activity{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String[] testArray = &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public static final&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; String TEST_ARRAY = “KEY_FOR_ARRAY”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; onCreate(Bundle State){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(State != &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0.0001pt 1.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;testArray = &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0.0001pt 1.5in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;State.getStringArray(SampleActivity.TEST_ARRAY);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testArray = &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; String[6];&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0.0001pt 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-indent: 0.5in;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; onSaveInstanceState(Bundle outstate){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0.0001pt 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;outstate.putStringArray(SampleActivity.TEST_ARRAY,&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0.0001pt 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testArray);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Otherwise your activity will use the default implementation of this function which saves some amount of state.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Some of the values that you can save before orientation change are as follows:&lt;/span&gt;&lt;/div&gt;&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black;&quot;&gt;Serializable      and its subclasses.&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black;&quot;&gt;String&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black;&quot;&gt;Parcelable      and its Subclasses&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black;&quot;&gt;boolean,      int, float.&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black;&quot;&gt;Arrays      etc.&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;However you may not want to store the values because this may slow down your application you can attain faster screen orientation by caching the data before orientation changes.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Your activity can cache data before rotation this can be accomplished by overriding&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt; Object onRetainNonConfigurationInstance()&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Let’s take the above example again but instead of saving the String array we’ll cache the data and retrieve reference to that after restart.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public class&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; SampleActivity &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;extends&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; Activity{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String[] testArray = &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public static final&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; String TEST_ARRAY = “KEY_FOR_ARRAY”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public void&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; onCreate(Bundle State){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0.0001pt 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;testArray = (String[])getLastNonConfigurarionInstance();&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0.0001pt 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;if(testArray == &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin: 0in 0in 0.0001pt 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testArray = &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; String[6];&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Override&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-indent: 0.5in;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public Object&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; onRetainNonConfigurationInstance(){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;return&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; testArray;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt; text-indent: 0.5in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt; line-height: 115%;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Change orientation at runtime&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;You can use Activity.setRequestedOrientation() from your activity to set that orientation&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;e.g. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;if you do not use this the default value is SCREEN_ORIENTATION_UNSPECIFIED and you must not specify any orientation in Applications manifest XML. And each time orientation is changed the activity is stopped and restarted.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black;&quot;&gt;Check orientation settings&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;You can query the orientation settings for device using&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public static int&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;myOrient;&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;myOrient = &lt;/span&gt;&lt;b&gt;&lt;span style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;.getResources().getConfiguration().orientation;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;this function will return either of the following values:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;ORIENTATION_LANDSCAPE or ORIENTATION_PORTRAIT, it can also return ORIENTATION_SQUARE on a square device.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: 0.0001pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;a href=&quot;http://androiddeveloperuser.blogspot.com/2011/06/handling-screen-orientation-part-1.html&quot;&gt;&amp;lt;&amp;lt;Handling Screen Orientation - Part 1&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;Cheers!!&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt; Vivek Jain&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Hello   Everyone, I came across an application which allowed me to produce  nice  effects on Images that are in my phone and Images that I take from  my  phones camera, its available here,&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B004WPVVU2/ref=mas_pm_pix_dp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span&gt;http://www.amazon.com/gp/produ&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;&lt;span&gt;ct/B004WPVVU2/ref=mas_pm_pix_d&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;p&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/8669093079737711659/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/06/handling-screen-orientation-part-2.html#comment-form' title='15 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/8669093079737711659'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/8669093079737711659'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/06/handling-screen-orientation-part-2.html' title='Handling Screen Orientation - Part 2'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><thr:total>15</thr:total></entry><entry><id>tag:blogger.com,1999:blog-512998992927617317.post-3257350216137283852</id><published>2011-06-12T22:51:00.000-07:00</published><updated>2011-06-16T20:53:22.027-07:00</updated><title type='text'>Handling Screen Orientation - Part 1</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Sometimes or I may say many times user will want to rotate the screen – this may be because user wants to view the app in landscape mode, or user wants to type something using on-screen keyboard.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;If user rotates the device from portrait to landscape, your app must rotate with it or must handle the change elegantly, but the question is how??&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;So let’s begin exploring the answer to this question….&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;First of all let us understand the concept of rotation and how you can set the behavior in your Android powered device.&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt; line-height: 115%;&quot;&gt;On your device’s home screen go to press “MENU” key and go to “SETTINGS” menu and then go to “DISPLAY SETTINGS” You will see the “Orientation/ Auto-rotate screen” option somewhat like this.&lt;/span&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/AVvXsEjZO9izGkKU-A38eYgT1w7IQtHeh1D28MR8EseEtlPGS8NddCJfabZt8jJQBakQUUw1dxT6PZNBsJzLBL8FHXSkp4IOwsM0L6nOyU-RTLcF53WSbpvZntx-Uz-_QJJ4BxGzux24YlzWEnVL/s1600/upload.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZO9izGkKU-A38eYgT1w7IQtHeh1D28MR8EseEtlPGS8NddCJfabZt8jJQBakQUUw1dxT6PZNBsJzLBL8FHXSkp4IOwsM0L6nOyU-RTLcF53WSbpvZntx-Uz-_QJJ4BxGzux24YlzWEnVL/s320/upload.jpg&quot; width=&quot;180&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;font-family: &amp;quot;Calibri&amp;quot;,&amp;quot;sans-serif&amp;quot;; font-size: 11pt; line-height: 115%;&quot;&gt;&amp;nbsp;&lt;/span&gt;  &lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;Note: Location may change based on the Android OS version.&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;When this option is unchecked, then screen display changes from portrait to landscape if the on – screen keyboard is open and back to portrait when it is closed but nothing happens when user actually rotates the device.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;With this setting on screen display always changes when keyboard is open and when user changes the device orientation.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Now let’s see how you can handle this change in your application, there are three things that you must do in your application:&lt;/div&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;1.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;You should always create layouts that can handle orientation and should always create separate layouts for portrait and landscape modes; we’ll see how you can do this later.&lt;/li&gt;
&lt;/ol&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;2.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Then set the orientation behavior in the Application’s manifest file.&lt;/li&gt;
&lt;/ol&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;3.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Then handle the rotation by handling appropriate events in your code.&lt;/li&gt;
&lt;/ol&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Now let’s start with these points.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;Creating layouts that can handle rotation&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Now with this I mean that your layout should be able to adjust itself whenever some change like this happens, it’ll be better if your application can provide different layouts for different orientations.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Wherever possible choose from the layouts which adjust to the orientation changes:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;LinearLayout, RelativeLayout, or TableLayouts&lt;/span&gt; are some of the layouts that that adjust for screen changes, but it might not be a good way because the screen designed for portrait mode might not work for landscape mode and vice versa, so, it’s better to have different layouts for both the modes.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: blue;&quot;&gt;These specialized layouts for Portrait and Landscape modes go in Separate specialized folders “res/layout” for Portrait mode and “res/layout-land” for landscape mode, you can also on similar lines have separate folders for drawables as well.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;Setting rotation behavior in Application’s manifest file&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;This only involves adding one parameter “&lt;span style=&quot;color: blue;&quot;&gt;android:screenOrientation&lt;/span&gt;” in &amp;lt;activity&amp;gt; tag in your manifest XML for each activity that must handle rotation.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;If you omit this parameter default will be whatever you have set in “DISPLAY SETTINGS” i.e.whatever is “Auto-rotate screen/Orientation” setting. This actually has some benefits listed as below:&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpFirst&quot; style=&quot;text-indent: -0.25in;&quot;&gt;1.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;If your application uses intents to call some other application views, then, using Orientation settings your app user will not have to turn device to move to that view and turn back to move to your app.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpMiddle&quot; style=&quot;text-indent: -0.25in;&quot;&gt;2.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;User is free to choose orientation behavior, more preferable by most users.&lt;/div&gt;&lt;div class=&quot;MsoListParagraphCxSpLast&quot; style=&quot;text-indent: -0.25in;&quot;&gt;3.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Makes your app more compatible with wide array of Android devices.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;Setting this parameter as “&lt;span style=&quot;color: blue;&quot;&gt;android:screenOrientation=”unspecified&lt;/span&gt;”” or “&lt;span style=&quot;color: blue;&quot;&gt;android:screenOrientation=”user”&lt;/span&gt; will also have the same effect as not specifying at all&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;If you set this parameter as “&lt;span style=&quot;color: blue;&quot;&gt;android:screenOrientation=”sensor”&lt;/span&gt;” this will mean that display will always rotate when the device is turned or the on-screen keyboard is opened or closed, irrespective of “Orientation” settings.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;If you set this parameter as “&lt;span style=&quot;color: blue;&quot;&gt;android:screenOrientation=”portrait”&lt;/span&gt;” or “landscape” your activity will remain in one orientation even if the device is rotated or on-screen keyboard is opened or closed. You’ll also not have to worry about layouts that adjust to orientation changes or handle roation in your code.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-align: right;&quot;&gt;&lt;a href=&quot;http://androiddeveloperuser.blogspot.com/2011/06/handling-screen-orientation-part-2.html&quot;&gt;Handling Screen Orientation - Part 2 &amp;gt;&amp;gt;&amp;nbsp;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;Cheers!!&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt; Vivek Jain&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Hello  Everyone, I came across an application which allowed me to produce nice  effects on Images that are in my phone and Images that I take from my  phones camera, its available here,&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B004WPVVU2/ref=mas_pm_pix_dp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span&gt;http://www.amazon.com/gp/produ&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;&lt;span&gt;ct/B004WPVVU2/ref=mas_pm_pix_d&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;p&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt; &lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/3257350216137283852/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/06/handling-screen-orientation-part-1.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/3257350216137283852'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/3257350216137283852'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/06/handling-screen-orientation-part-1.html' title='Handling Screen Orientation - Part 1'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZO9izGkKU-A38eYgT1w7IQtHeh1D28MR8EseEtlPGS8NddCJfabZt8jJQBakQUUw1dxT6PZNBsJzLBL8FHXSkp4IOwsM0L6nOyU-RTLcF53WSbpvZntx-Uz-_QJJ4BxGzux24YlzWEnVL/s72-c/upload.jpg" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-512998992927617317.post-7967454742296236856</id><published>2011-05-21T01:47:00.000-07:00</published><updated>2011-06-16T20:54:02.044-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="Cookies"/><category scheme="http://www.blogger.com/atom/ns#" term="handling"/><category scheme="http://www.blogger.com/atom/ns#" term="Permanent"/><category scheme="http://www.blogger.com/atom/ns#" term="RAM"/><category scheme="http://www.blogger.com/atom/ns#" term="SD Card"/><category scheme="http://www.blogger.com/atom/ns#" term="sync"/><category scheme="http://www.blogger.com/atom/ns#" term="Synchronization"/><category scheme="http://www.blogger.com/atom/ns#" term="WebView"/><title type='text'>WebView - Part 4 Handling Cookies in WebView</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;Handling Cookies in WebView&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;Actually this is very simple, as we mentioned in Part 1 of this series, that for security reasons, your application will have its own cache and its own cookie store i.e. it doesn’t share the Browser’s application data, cookies are also managed in separate thread which means that those operations which are for managing cookies (e.g. building index) will not block your application’s UI thread.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;Now, we use “android.webkit.CookieSyncManager” class to manage cookies particularly to synchronize the browser cookies between RAM and permanent storage. To get maximum efficiency cookies are stored in RAM and a separate thread is used to save cookies this thread is driven by timer, sync interval is of 5 Minutes.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;To use CookieSyncManager all you have to do is add these three lines in your code&lt;/span&gt;&lt;/div&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;Call this when the application starts.&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;CookieSyncManager&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;createInstance&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;context&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;To set up sync call in Activity.onResume()&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;CookieSyncManager.getInstance().startSync();&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;and lastly, call this in Activity.onPause()&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;CookieSyncManager.getInstance().stopSync();&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;To get sync instantly without waiting for the timer to trigger, host can call&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;CookieSyncManager.getInstance().sync();&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;But be aware that this sync also happens asynchronously, so don’t do it just as your activity is shutting down.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 class=&quot;post-title entry-title&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;a href=&quot;http://androiddeveloperuser.blogspot.com/2011/05/webview-part-3-how-to-customize-webview.html&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&amp;lt;WebView - Part 3 How to customize WebView?&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Times New Roman&amp;quot;,&amp;quot;serif&amp;quot;; font-size: 12pt;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;Cheers!!&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt; Vivek Jain&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Hello   Everyone, I came across an application which allowed me to produce  nice  effects on Images that are in my phone and Images that I take from  my  phones camera, its available here,&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B004WPVVU2/ref=mas_pm_pix_dp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span&gt;http://www.amazon.com/gp/produ&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;&lt;span&gt;ct/B004WPVVU2/ref=mas_pm_pix_d&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;p&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;a href=&quot;http://www.amazon.com/Product-Labz-Pixel/dp/B004WPVVU2&quot;&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/7967454742296236856/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/webview-part-4-handling-cookies-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/7967454742296236856'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/7967454742296236856'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/webview-part-4-handling-cookies-in.html' title='WebView - Part 4 Handling Cookies in WebView'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-512998992927617317.post-4476108078475981265</id><published>2011-05-21T01:45:00.000-07:00</published><updated>2011-06-16T20:54:21.660-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="customize"/><category scheme="http://www.blogger.com/atom/ns#" term="injecting"/><category scheme="http://www.blogger.com/atom/ns#" term="intercepting"/><category scheme="http://www.blogger.com/atom/ns#" term="Javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="override"/><category scheme="http://www.blogger.com/atom/ns#" term="Settings"/><category scheme="http://www.blogger.com/atom/ns#" term="UI"/><category scheme="http://www.blogger.com/atom/ns#" term="URL"/><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><category scheme="http://www.blogger.com/atom/ns#" term="WebView"/><title type='text'>WebView - Part 3 How to customize WebView?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;a href=&quot;http://www.amazon.com/Product-Labz-Pixel/dp/B004WPVVU2&quot;&gt;http://www.amazon.com/Product-Labz-Pixel/dp/B004WPVVU2&lt;/a&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span lang=&quot;EN-IN&quot;&gt;How to customize WebView?&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;WebViews can be customized in Variety of ways, where you can add your own behaviour; this can be done in following ways:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.75in; text-indent: -0.25in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;1.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Overriding “android.webkit.WebChromeClient” class we can override the UI behaviour, because this class or subclass of this class is called when something that may effect the UI happens, e.g. progress update and Javascript Alerts &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.75in; text-indent: -0.25in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;2.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Overriding “android.webkit.WebViewClient” class we can override page loading behaviour; because this class or its subclass is called whenever something that can impact page rendering happens e.g. errors or form submissions. You can also intercept URLs here.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.75in; text-indent: -0.25in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;3.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt;You can also modify the “android.webkit.WebSettings” class e.g. you can enable JavaScript with setJavaScriptEnabled() method.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.75in; text-indent: -0.25in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;4.&lt;span style=&quot;font: 7pt &amp;quot;Times New Roman&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt;You can also add JavaScript to Java interfaces with the addJavaScriptInterface(Object, String) method. This method lets you bind Java Object into the WebView so that they can be controlled by web pages JavaScript&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Here we’ll discuss all of them one by one.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Handling UI State with WebChromeClient Class:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Here in this sample we are overriding the Progress of page loading for this we’ll override WebChromeClient.onProgressChanged method this sample will also explain the way of getting the Settings for your WebView and setting some of the settings e.g. enabling JavaScript.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;So, here’s the Sample code that you can use in your activity:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;browser&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; = (WebView)findViewById(R.id.&lt;/span&gt;&lt;i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;webbrowser&lt;/span&gt;&lt;/i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;);&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;getWindow().requestFeature(Window.&lt;/span&gt;&lt;i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;FEATURE_PROGRESS&lt;/span&gt;&lt;/i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;);&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;background: none repeat scroll 0% 0% silver; color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;browser&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;.getSettings().setJavaScriptEnabled(&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;);&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;background: none repeat scroll 0% 0% silver; color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;browser&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;.setWebChromeClient(&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; WebChromeClient(){&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; onProgressChanged(WebView View, &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; progress){&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WebBrowser.&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;.setProgress(progress * 1000);&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;});&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;So, here in first line we are getting reference to WebView widget that we have specified in XML in this layout.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;Then we request FEATURE_PROGRESS feature of this activity’s Window this will display the progress in Title bar of the window and progress will automatically disappear when it reaches 100%.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;Then we call getSettings() method of WebView this method returns the reference to WebSettings class’s object associated with this WebView object. &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt;When a WebView is first created, it obtains a set of default settings. These default settings will be returned from any getter call. A WebSettings object obtained from WebView.getSettings() is tied to the life of the WebView. If a WebView has been destroyed, any method call on WebSettings will throw an IllegalStateException.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;We use this reference to enable JavaScript on this WebView object.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Next, we are setting a new object for WebChromeClient of WebView and overriding its onProgressChanged method, this method tells the host application about the progress of loading the page.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Handling page loading behaviour using WebViewClient class:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;browser&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;.setWebViewClient(&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; WebViewClient(){&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;u&gt;onRecievedError(WebView View, &lt;/u&gt;&lt;/span&gt;&lt;b&gt;&lt;u&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;u&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; errorCode, &lt;/span&gt;&lt;/u&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1in;&quot;&gt;&lt;u&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;String description, String failingURL)&lt;/span&gt;&lt;/u&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;{&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AlertDialog.Builder dlg = &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AlertDialog.Builder(WebBrowser.&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;);&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dlg.setMessage(description);&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dlg.setTitle(R.string.&lt;/span&gt;&lt;i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;app_name&lt;/span&gt;&lt;/i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;);&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dlg.setPositiveButton(R.string.&lt;/span&gt;&lt;i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #0000c0; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;ok_button&lt;/span&gt;&lt;/i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;, &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;DialogInterface.OnClickListener() {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; onClick(DialogInterface &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 2.5in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;arg0, &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;int&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt; arg1) {&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Here, we are setting a new object for WebViewClient of WebView and overriding its onRecievedError method, this method is called whenever there is some error in loading the page.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Similar to this approach you can override the&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;boolean&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;shouldOverrideUrlLoading(WebView view, String url)&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;method of WebViewClient; this method returns “&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot;&gt;” if it is overriding the Url Loading otherwise “&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: &amp;quot;Courier New&amp;quot;; font-size: 10pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot;&gt;”&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Adding Javascript to Java interfaces&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; Context myApp = &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;this&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #3f7f5f; font-family: Consolas; font-size: 9pt;&quot;&gt;/* An instance of this class will be registered as a JavaScript interface */&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;class&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; MyJavaScriptInterface { &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;@SuppressWarnings(&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;&quot;unused&quot;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;) &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; showHTML(String html) { &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.5in; text-indent: 0.5in;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; AlertDialog.Builder(myApp) &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;.setTitle(&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;&quot;HTML&quot;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;) &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;.setMessage(html) &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;.setPositiveButton(android.R.string.ok, &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;null&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;) .setCancelable(&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;false&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;)&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;.create() &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;.show(); &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;} &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;} &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;final&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; WebView browser = (WebView)findViewById(R.id.browser); &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #3f7f5f; font-family: Consolas; font-size: 9pt;&quot;&gt;/* JavaScript must be enabled if you want it to work, obviously */&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; browser.getSettings().setJavaScriptEnabled(&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;true&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;); &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #3f7f5f; font-family: Consolas; font-size: 9pt;&quot;&gt;/* Register a new JavaScript interface called HTMLOUT */&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; browser.addJavascriptInterface(&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; MyJavaScriptInterface(), &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;&quot;HTMLOUT&quot;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;); &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #3f7f5f; font-family: Consolas; font-size: 9pt;&quot;&gt;/* WebViewClient must be set BEFORE calling loadUrl! */&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; browser.setWebViewClient(&lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;new&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; WebViewClient() { @Override &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;public&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #7f0055; font-family: Consolas; font-size: 9pt;&quot;&gt;void&lt;/span&gt;&lt;/b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; onPageFinished(WebView view, String url) { &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #3f7f5f; font-family: Consolas; font-size: 9pt;&quot;&gt;/* This call inject JavaScript into the page which just finished loading. */&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; browser.loadUrl(&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;&quot;javascript:window.HTMLOUT.showHTML(&#39;&amp;lt;head&amp;gt;&#39;+document.getElementsBy&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;TagName(&#39;html&#39;)&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;[0].innerHTML+&#39;&amp;lt;/head&amp;gt;&#39;);&quot;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;); } }); &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: #3f7f5f; font-family: Consolas; font-size: 9pt;&quot;&gt;/* load a web page */&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;browser.loadUrl(&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: blue; font-family: Consolas; font-size: 9pt;&quot;&gt;&quot;someUrl&quot;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black; font-family: Consolas; font-size: 9pt;&quot;&gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul style=&quot;margin-top: 0in;&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;First, a class called MyJavaScriptInterface is defined. It      implements a single public method&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt;showHTML() which displays a dialog      with the HTML it receives as a parameter.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;Then, an instance of this class is      registered as a JavaScript interface called HTMLOUT. The&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;span style=&quot;color: black;&quot;&gt;showHTML() method can now be      accessed from JavaScript like this:&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;window.HTMLOUT.showHTML(‘…’)&lt;/span&gt;      &lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;In order to call showHTML() when the page      finishes loading, a &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: blue;&quot;&gt;WebViewClient&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt; instance which&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;span style=&quot;color: black;&quot;&gt;overrides &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;onPageFinished&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;() is added to the WebView. When the page finishes      loading, this method will&lt;/span&gt; &lt;span style=&quot;color: black;&quot;&gt;inject a piece      of JavaScript code into the page, using &lt;/span&gt;&lt;span style=&quot;color: blue;&quot;&gt;the      method I described in an earlier post&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;/span&gt;      &lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;Finally, a web page is loaded.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;showHTML method can also be called from other Javascript that may get loaded into your browser control, so, use carefully.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;h3 class=&quot;post-title entry-title&quot;&gt;&lt;a href=&quot;http://androiddeveloperuser.blogspot.com/2011/05/webview-part-2-accesing-files-on-device.html&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;WebView - Part 2 Accesing Files on Device and in APK itself&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;&amp;nbsp; &lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;h3 class=&quot;post-title entry-title&quot;&gt;&lt;a href=&quot;http://androiddeveloperuser.blogspot.com/2011/05/webview-part-4-handling-cookies-in.html&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;WebView - Part 4 Handling Cookies in WebView&amp;gt;&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Cheers!!&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt; Vivek Jain&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Hello   Everyone, I came across an application which allowed me to produce  nice  effects on Images that are in my phone and Images that I take from  my  phones camera, its available here,&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B004WPVVU2/ref=mas_pm_pix_dp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span&gt;http://www.amazon.com/gp/produ&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;&lt;span&gt;ct/B004WPVVU2/ref=mas_pm_pix_d&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;p&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;a href=&quot;http://www.amazon.com/Product-Labz-Pixel/dp/B004WPVVU2&quot;&gt;&lt;/a&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/4476108078475981265/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/webview-part-3-how-to-customize-webview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/4476108078475981265'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/4476108078475981265'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/webview-part-3-how-to-customize-webview.html' title='WebView - Part 3 How to customize WebView?'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-512998992927617317.post-9183467897716351664</id><published>2011-05-19T21:47:00.000-07:00</published><updated>2011-06-16T20:54:42.533-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="accessing"/><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="APK"/><category scheme="http://www.blogger.com/atom/ns#" term="files"/><category scheme="http://www.blogger.com/atom/ns#" term="images"/><category scheme="http://www.blogger.com/atom/ns#" term="SD Card"/><category scheme="http://www.blogger.com/atom/ns#" term="WebView"/><title type='text'>WebView - Part 2 Accesing Files on Device and in APK itself</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 16pt;&quot;&gt;Accessing files in Android device using WebView&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 16pt;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;For using WebView you must have the permissions to access INTERNET and to request permission to access INTERNET just add the following line in your application&#39;s manifest just under &amp;lt;/application&amp;gt; tag&amp;nbsp; i.e. make it a child of manifest tag.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 16pt;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;span style=&quot;font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;code&gt;&amp;lt;uses-permission android:name=&quot;android.permission.INTERNET&quot;/&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 16pt;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Create the following HTML either programmatically using code in String format or create the file and save that in /res/value/string.xml and name it as &amp;lt;somename&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Test File Loading&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;body&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;Here we are loading the image file in HTML &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;To display:&amp;lt;br&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;img height=”100” width=”100” src=&lt;a href=&quot;http://www.blogger.com/yourimagefilepath&quot;&gt;file:///yourimagefilepath&lt;/a&gt;&amp;gt;&amp;lt;/img&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;To reference the file in &amp;lt;img&amp;gt; tag, you have to use the file URI pointing to the location where the file is saved.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Here’s the Java code to load this HTML into a WebKit component:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;WebView web = (WebView)findViewById(R.id.web_view);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;final String mimeType = “text/html”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final String encoding = “UTF-8”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;String htmldata = &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getResources().getString(R.string.&amp;lt;somename&amp;gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(htmldata != null){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; web.loadData(html,&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mimeType,&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; encoding);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;else{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;web.loadData(“&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;Failed&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;”&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,mimeType, encoding);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Now, you should be able to see image in your WebView&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 16pt;&quot;&gt;Accessing resources bundled with APK&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Create the following HTML either programmatically using code in String format or create the file and save that in /res/value/string.xml and name it as &amp;lt;somename&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;html&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;head&amp;gt;&amp;lt;title&amp;gt;Test File Loading&amp;lt;/title&amp;gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;body&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;Here we are loading the image file in HTML &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;To display:&amp;lt;br&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;lt;img height=”100” width=”100” src=file:///android_asset/imagename&amp;gt;&amp;lt;/img&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;To reference the file in &amp;lt;img&amp;gt; tag, you have to use the file URI pointing to the /android_asset/imagename.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Here’s the Java code to load this HTML into a WebKit component:&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;WebView web = (WebView)findViewById(R.id.web_view);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;final String mimeType = “text/html”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; final String encoding = “UTF-8”;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;String htmldata = &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; getResources().getString(R.string.&amp;lt;somename&amp;gt;);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(htmldata != null){&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; web.loadData(html,&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mimeType,&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; encoding);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;else{&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;web.loadData(“&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;Failed&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;”&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 0.5in; text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ,mimeType, encoding);&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;text-indent: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;Courier New&amp;quot;;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Now, you should be able to see image in your WebView.&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;h3 class=&quot;post-title entry-title&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;a href=&quot;http://androiddeveloperuser.blogspot.com/2011/05/webview-part-1-capabilities-and.html&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;lt;&amp;lt;WebView – Part 1 Capabilities and Limitations&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;h3 class=&quot;post-title entry-title&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;a href=&quot;http://androiddeveloperuser.blogspot.com/2011/05/webview-part-3-how-to-customize-webview.html&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;WebView - Part 3 How to customize WebView?&amp;gt;&amp;gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;Cheers!!&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt; Vivek Jain&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Hello   Everyone, I came across an application which allowed me to produce  nice  effects on Images that are in my phone and Images that I take from  my  phones camera, its available here,&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B004WPVVU2/ref=mas_pm_pix_dp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span&gt;http://www.amazon.com/gp/produ&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;&lt;span&gt;ct/B004WPVVU2/ref=mas_pm_pix_d&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;p&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/9183467897716351664/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/webview-part-2-accesing-files-on-device.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/9183467897716351664'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/9183467897716351664'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/webview-part-2-accesing-files-on-device.html' title='WebView - Part 2 Accesing Files on Device and in APK itself'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-512998992927617317.post-822370151499077375</id><published>2011-05-18T20:42:00.000-07:00</published><updated>2011-06-16T20:55:02.855-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="Capabilities"/><category scheme="http://www.blogger.com/atom/ns#" term="Cookies"/><category scheme="http://www.blogger.com/atom/ns#" term="how to"/><category scheme="http://www.blogger.com/atom/ns#" term="Limitations"/><category scheme="http://www.blogger.com/atom/ns#" term="screen density"/><category scheme="http://www.blogger.com/atom/ns#" term="UserInterface"/><category scheme="http://www.blogger.com/atom/ns#" term="WebKit"/><category scheme="http://www.blogger.com/atom/ns#" term="WebView"/><category scheme="http://www.blogger.com/atom/ns#" term="Window Management"/><title type='text'>WebView – Part 1 Capabilities and Limitations</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;WebView is actually a WebKit canvas for Android platform, WebKit is open source browser engine which is also being used in Apple’s Safari.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;This blog outlines many things if not everything about WebView.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 14pt;&quot;&gt;Capabilities&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;It is possible to intercept the events in the WebView to      overload many of the default behaviour e.g. we can overload the behaviour      when Page loading is completed, similarly, loads of other events can be      overloaded to customize the behaviour of WebView in specific      circumstances.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Assets like Videos and Images can be referenced from HTML      running in WebView; even the Assets from APK file can be loaded.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Assets can also be downloaded over internet and saved into      Android device then these Assest can be loaded in HTML.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;This Widget can be used to load and display HTML’s over the      network just like normal web browser.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;HTML’s that are saved on Android device can also be loaded in      WebView.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;HTML can also be dynamically generated and viewed in WebView,      e.g. we can generate HTML based on certain parameter that depends on Time      elapsed like we can use GPS and Time elapsed to calculate the distance      covered and then display the results in format of Dynamically generated      HTML into WebView.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;HTML code can also be presented in Application resources inside      the APK file, this approach can be used to display predetermined data in a      formatted way using HTML and WebView&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 14pt;&quot;&gt;Limitations&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;ol start=&quot;1&quot; style=&quot;margin-top: 0in;&quot; type=&quot;1&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Its not easy to intercept the events generated by WebView      component&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;There are many events that cannot be intercepted, and there is      limitation in what behaviours can be overloaded, which limits the      customization of this component and changing the default behaviour of this      component difficult.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;By default, a WebView provides no browser-like widgets, does      not enable JavaScript and web page errors are ignored. If your application      has such requirements it better to invoke Browser application than using      WebView like this:&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;pre&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;        Uri&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; uri &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Uri&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;parse&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;(&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;color: #3366ff;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&quot;http://www.example.com&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot;&gt;
&lt;span class=&quot;pln&quot;&gt;        &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; intent &lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;color: #660000; font-weight: bold;&quot;&gt;new&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; &lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;typ&quot;&gt;Intent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;color: #3366ff; font-style: italic;&quot;&gt;ACTION_VIEW&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt; uri&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;
&lt;span class=&quot;pln&quot;&gt;        startActivity&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;intent&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;font-family: georgia; font-weight: bold; margin-left: 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 85%;&quot;&gt;4.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 85%;&quot;&gt;By default, requests by the HTML to open new windows are ignored&lt;/span&gt;&lt;span style=&quot;font-size: 85%;&quot;&gt;.&lt;/span&gt;&lt;/pre&gt;&lt;pre style=&quot;font-family: georgia; font-weight: bold; margin-left: 0.5in; text-indent: -0.25in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 85%;&quot;&gt;5.&lt;span style=&quot;font-size-adjust: none; font-stretch: normal; font-style: normal; font-variant: normal; font-weight: normal; line-height: normal;&quot;&gt;      &lt;/span&gt;&lt;/span&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 85%;&quot;&gt;By default, requests by the HTML to open new windows are ignored&lt;/span&gt;&lt;/pre&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-left: 1in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span style=&quot;font-size: 130%;&quot;&gt;&lt;b&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Cookie and Window Management&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;For security reasons, your application has its own cache, cookie store – it doesn’t share browser data. Cookies will be managed in separate thread so that heavy operations related to cookies can’t block UI thread. “CookieSyncManager” is used to synchronize cookies between RAM and permanent storage, so this class must be used if you want to use cookies in your application.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;By default, requests by the HTML to open new windows are ignored, no matter if the link is being opened by Javascript or by the target attribute on a link. You can customize your WebChromeClient to provide your own behaviour for opening multiple windows&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;You can set your activity to handle orientation and keyboardHidden changes WebView will automatically re-orient it.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;margin: 0in 0in 0.0001pt;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Building web pages to support different screen densities&lt;/span&gt;&lt;/h3&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;By default, WebView scales a web page so that it is drawn at a size that matches the default appearance on a medium density screen. So, it applies 1.5x scaling on a high density screen (because its pixels are smaller) and 0.75x scaling on a low density screen (because its pixels are bigger). Starting with API Level 5 (Android 2.0), WebView supports DOM, CSS, and META tag features to help you (as a web developer) target screens with different screen densities.&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Here&#39;s a summary of the features you can use to handle different screen densities:&lt;/span&gt;&lt;br /&gt;
&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;The &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;window.devicePixelRatio&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; DOM property. The value of this property specifies the default      scaling factor used for the current device. For example, if the value of &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;window.devicePixelRatio&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; is &quot;1.0&quot;, then the device is considered a medium      density (mdpi) device and default scaling is not applied to the web page;      if the value is &quot;1.5&quot;, then the device is considered a high      density device (hdpi) and the page content is scaled 1.5x; if the value is      &quot;0.75&quot;, then the device is considered a low density device      (ldpi) and the content is scaled 0.75x. However, if you specify the &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;&quot;target-densitydpi&quot;&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; meta property (discussed below), then you can stop this      default scaling behavior.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;The &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;-webkit-device-pixel-ratio&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; CSS media query. Use this to specify the screen densities for      which this style sheet is to be used. The corresponding value should be      either &quot;0.75&quot;, &quot;1&quot;, or &quot;1.5&quot;, to indicate      that the styles are for devices with low density, medium density, or high      density screens, respectively. For example: &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;pre style=&quot;margin-left: 0.5in;&quot;&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&lt;link&gt;&lt;/link&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atn&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;rel&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atv&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&quot;stylesheet&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atn&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;media&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atv&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&quot;screen and (-webkit-device-pixel-ratio:1.5)&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atn&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;href&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atv&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&quot;hdpi.css&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div style=&quot;margin-left: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;The &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;hdpi.css&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; stylesheet is only used for devices with a screen pixel ration of 1.5, which is the high density pixel ratio.&lt;/span&gt;&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;The &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;target-densitydpi&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; property for the &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;viewport&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; meta tag.      You can use this to specify the target density for which the web page is      designed, using the following values: &lt;/span&gt;&lt;/li&gt;
&lt;ul type=&quot;circle&quot;&gt;&lt;li class=&quot;MsoNormal&quot;&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;device-dpi&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; - Use the device&#39;s native dpi as the target dpi. Default       scaling never occurs.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;high-dpi&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; - Use hdpi as the target dpi. Medium and low density screens       scale down as appropriate.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;medium-dpi&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; - Use mdpi as the target dpi. High density screens scale up       and low density screens scale down. This is also the default behavior.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;low-dpi&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; - Use ldpi as the target dpi. Medium and high density screens       scale up as appropriate.&lt;/span&gt;&lt;/li&gt;
&lt;li class=&quot;MsoNormal&quot;&gt;&lt;code&gt;&lt;i&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;&lt;value&gt;&lt;/value&gt;&lt;/span&gt;&lt;/i&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; - Specify a dpi value to use as the target dpi (accepted       values are 70-400).&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/ul&gt;&lt;div style=&quot;margin-left: 0.5in;&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;Here&#39;s an example meta tag to specify the target density:&lt;/span&gt;&lt;/div&gt;&lt;pre style=&quot;margin-left: 0.5in;&quot;&gt;&lt;span class=&quot;tag&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atn&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;name&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atv&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&quot;viewport&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atn&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;content&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pun&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;=&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;atv&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;&quot;target-densitydpi=device-dpi&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;pln&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;tag&quot;&gt;&lt;span lang=&quot;EN-IN&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;span lang=&quot;EN-IN&quot;&gt;If you want to modify your web page for different densities, by using the &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;-webkit-device-pixel-ratio&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; CSS media query and/or the &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;window.devicePixelRatio&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; DOM property, then you should set the &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;target-densitydpi&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt; meta property to &lt;/span&gt;&lt;code&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-size: 10pt;&quot;&gt;device-dpi&lt;/span&gt;&lt;/code&gt;&lt;span lang=&quot;EN-IN&quot;&gt;. This stops Android from performing scaling in your web page and allows you to make the necessary adjustments for each density via CSS and JavaScript.&lt;/span&gt;&lt;br /&gt;
&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: georgia; font-size: 85%;&quot;&gt;It is always best to let the WebView take the full space available in parent’s ViewGroup object, because WebView component doesn’t know about it’s size until it loads HTML into it. So its best to set size of WebView while placing it into a ViewGroup, and then load HTML into it. Otherwise there are issues with WebView. &lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: right;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: georgia; font-size: 85%;&quot;&gt;                                                                              &lt;/span&gt;&lt;br /&gt;
&lt;h3 class=&quot;post-title entry-title&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;a href=&quot;http://androiddeveloperuser.blogspot.com/2011/05/webview-part-2-accesing-files-on-device.html&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;WebView - Part 2 Accesing Files on Device and in APK itself&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;&lt;span style=&quot;font-size: 78%;&quot;&gt;&lt;span lang=&quot;EN-IN&quot; style=&quot;font-family: &amp;quot;; font-size: 16pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Cheers!!&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Vivek Jain&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Hello   Everyone, I came across an application which allowed me to produce  nice  effects on Images that are in my phone and Images that I take from  my  phones camera, its available here,&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B004WPVVU2/ref=mas_pm_pix_dp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;http://www.amazon.com/gp/produ&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;ct/B004WPVVU2/ref=mas_pm_pix_d&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;p&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/822370151499077375/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/webview-part-1-capabilities-and.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/822370151499077375'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/822370151499077375'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/webview-part-1-capabilities-and.html' title='WebView – Part 1 Capabilities and Limitations'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-512998992927617317.post-7141494925809772378</id><published>2011-05-17T22:44:00.000-07:00</published><updated>2011-06-16T20:55:26.348-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Activity"/><category scheme="http://www.blogger.com/atom/ns#" term="Android"/><category scheme="http://www.blogger.com/atom/ns#" term="application"/><category scheme="http://www.blogger.com/atom/ns#" term="intent"/><category scheme="http://www.blogger.com/atom/ns#" term="launcher"/><category scheme="http://www.blogger.com/atom/ns#" term="shortcuts"/><category scheme="http://www.blogger.com/atom/ns#" term="User Interface"/><title type='text'>PROVIDING LAUNCHER SHORTCUT – Android</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;In this article we&#39;ll discuss how to provide facility to add shortcut to your activity to the launcher&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;Contents:&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;Adding shortcut to launcher&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;An activity actually handles two stages of launcher shortcut&#39;s life cycle.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;1.            Activity must provide the shortcuts to the launcher. That is, when the user installs a shortcut, your activity must generate the actual shortcut and returns it to the launcher along with the shortcut name and icon which will be displayed to user.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;2.            Whenever user clicks on your applications icon, intent is sent. Your activity typically handles this intent as necessary&lt;/div&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;Now let’s see how we can handle the stage 1.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;Your application simply creates an &quot;Intent&quot; that the launcher will use to create the shortcut.A more interactive way such as a User interface can be provided to user to make a more customizable shortcut.For example, Your User Interface may provide the way to select the specific nature of the shortcut, i.e. contact, picture, URL, media item etc.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;    //This function creates a shortcut and returns it to the caller.  There are actually two &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;    //intents that you will send back.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #663300; font-weight: bold;&quot;&gt;private void&lt;/span&gt; setupShortcut() {&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt; // First, set up the shortcut intent.  For this example, we simply create an intent that&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;        // will bring us directly back to this activity.  A more typical implementation would use a &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;        // data Uri in order to display a more specific result, or a custom action in order to &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;        // launch a specific operation.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Intent shortcutIntent = &lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Intent(Intent.&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;ACTION_MAIN&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
shortcutIntent.setClassName(&lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;this&lt;/span&gt;, &lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.getClass().getName());&lt;/span&gt;&lt;br /&gt;
shortcutIntent.putExtra(&lt;span style=&quot;color: #3333ff; font-style: italic;&quot;&gt;SHTCT_KEY&lt;/span&gt;, &lt;span style=&quot;color: #3366ff;&quot;&gt;&quot;Example Shortcut provided&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;// Then, set up the container intent (the response to the caller)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Intent intent = &lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Intent();&lt;br /&gt;
intent.putExtra(Intent.&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;EXTRA_SHORTCUT_INTENT&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, shortcutIntent);&lt;/span&gt;&lt;br /&gt;
intent.putExtra(Intent&lt;span style=&quot;color: black; font-style: italic;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;EXTRA_SHORTCUT_NAME&lt;/span&gt;, &lt;span style=&quot;color: #3366ff;&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
Parcelable iconResource = Intent.ShortcutIconResource.&lt;span style=&quot;color: black; font-style: italic;&quot;&gt;fromContext&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,  R.drawable.&lt;/span&gt;&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;icon&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
intent.putExtra(Intent.&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;EXTRA_SHORTCUT_ICON_RESOURCE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, iconResource);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #336666;&quot;&gt;// Now, return the result to the launcher&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
setResult(&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;RESULT_OK&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, intent);&lt;/span&gt;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;This function provides the Intent that will be returned to launcher in the container Intent .&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Intent shortcutIntent = &lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Intent(Intent.&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;ACTION_MAIN&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
shortcutIntent.setClassName(&lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;this&lt;/span&gt;, &lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.getClass().getName());&lt;/span&gt;&lt;br /&gt;
shortcutIntent.putExtra(&lt;span style=&quot;color: #3333ff; font-style: italic;&quot;&gt;SHTCT_KEY&lt;/span&gt;, &lt;span style=&quot;color: #3366ff;&quot;&gt;&quot;Example Shortcut provided&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;This is the intent that will be sent to your activity when user clicks Shortcut Icon.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;First we are setting up the shortcut intent. Here in this example we are telling launcher that we need to handle “ACTION_MAIN” Action i.e. this intent will bring us directly back to this activity. However you can use data Uri with Action as “ACTION_VIEW” to display more specific result, or, a custom action to launch a specific operation provided your Activity handles that Action which you must specify in “AndroidManifest.xml” in “intent-filter” tag of “activity” tag.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;Second we are setting up the class to call; in this case we are setting the class name for current activity but any other “class name” will also work provided that class can handle the Action specified in the intent.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;Next we’ll create the container Intent that will have the Shortcut specific information.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;// Then, set up the container intent (the response to the caller)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Intent intent = &lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;new&lt;/span&gt; Intent();&lt;br /&gt;
intent.putExtra(Intent.&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;EXTRA_SHORTCUT_INTENT&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, shortcutIntent);&lt;/span&gt;&lt;br /&gt;
intent.putExtra(Intent&lt;span style=&quot;color: black; font-style: italic;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;EXTRA_SHORTCUT_NAME&lt;/span&gt;, &lt;span style=&quot;color: #3366ff;&quot;&gt;&quot;Name&quot;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
Parcelable iconResource = Intent.ShortcutIconResource.&lt;span style=&quot;color: black; font-style: italic;&quot;&gt;fromContext&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;,  R.drawable.&lt;/span&gt;&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;icon&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;);&lt;/span&gt;&lt;br /&gt;
intent.putExtra(Intent.&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;EXTRA_SHORTCUT_ICON_RESOURCE&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, iconResource);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;Here, in second line we are specifying the Intent that will be sent back to the activity when user clicks the shortcut Icon.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Next we specify the name i.e. the text that’ll be displayed with the Icon.&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
And then the Icon itself&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;.&lt;br /&gt;
&lt;br /&gt;
Now, set the results for launcher to use&lt;/span&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #336666;&quot;&gt;// Now, return the result to the launcher&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
setResult(&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;RESULT_OK&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;, intent);&lt;/span&gt;&lt;span style=&quot;font-family: &amp;quot;; font-size: 11pt; line-height: 115%;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Now write the following code in onCreate method of your Activity&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;// Resolve the intent&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;final&lt;/span&gt; Intent intent = getIntent();&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt; &lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;final&lt;/span&gt;&lt;/span&gt; String action = intent.getAction();&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #006600;&quot;&gt;// If the intent is a request to create a shortcut, we&#39;ll do that and exit&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
if (Intent.&lt;span style=&quot;color: #3366ff; font-style: italic;&quot;&gt;ACTION_CREATE_SHORTCUT&lt;/span&gt;.equals(action)) {&lt;br /&gt;
setupShortcut();&lt;br /&gt;
finish();&lt;br /&gt;
&lt;span style=&quot;color: #660000; font-weight: bold;&quot;&gt;return&lt;/span&gt;;&lt;br /&gt;
}&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;Intent.ACTION_CREATE_SHORTCUT is sent to your activity by launcher when user has requested to create the Shortcut . &lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;So, in response to this Intent we set up the intent and finish the activity and return.&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;With this your process of adding Activity shortcut to Launcher is finished.&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;color: black; margin-bottom: 0.0001pt;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Cheers!!&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt; Vivek Jain&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Hello   Everyone, I came across an application which allowed me to produce  nice  effects on Images that are in my phone and Images that I take from  my  phones camera, its available here,&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;messageBody&quot; data-ft=&quot;{&amp;quot;type&amp;quot;:3}&quot;&gt;&lt;a href=&quot;http://www.amazon.com/gp/product/B004WPVVU2/ref=mas_pm_pix_dp&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span&gt;http://www.amazon.com/gp/produ&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;&lt;span&gt;ct/B004WPVVU2/ref=mas_pm_pix_d&lt;/span&gt;&lt;wbr&gt;&lt;/wbr&gt;&lt;span class=&quot;word_break&quot;&gt;&lt;/span&gt;p&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;img alt=&quot;&quot; src=&quot;file:///C:/DOCUME%7E1/vjain1/LOCALS%7E1/Temp/moz-screenshot.png&quot; /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/7141494925809772378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/providing-launcher-shortcut-android.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/7141494925809772378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/7141494925809772378'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/providing-launcher-shortcut-android.html' title='PROVIDING LAUNCHER SHORTCUT – Android'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-512998992927617317.post-4740452333278912052</id><published>2011-05-17T02:11:00.000-07:00</published><updated>2011-05-17T02:14:28.199-07:00</updated><title type='text'>The first post on Blog for Android Developers and Users</title><content type='html'>This blog is for Android Developers and Users alike, we&#39;ll be posting Android Phone usage tutorials,  Code Samples and other stuff to make life easier for people associated with android. Thankyou&lt;br /&gt;Vivek Jain</content><link rel='replies' type='application/atom+xml' href='http://androiddeveloperuser.blogspot.com/feeds/4740452333278912052/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/first-post-on-blog-for-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/4740452333278912052'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/512998992927617317/posts/default/4740452333278912052'/><link rel='alternate' type='text/html' href='http://androiddeveloperuser.blogspot.com/2011/05/first-post-on-blog-for-android.html' title='The first post on Blog for Android Developers and Users'/><author><name>Vicky Jain</name><uri>http://www.blogger.com/profile/10860842768973910635</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='27' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHTEp3uE8ZdTZj40Savwb-msRDIfe17RibQfFXaGOpjrfE58xVT0w_B69UXOuM58DXvHoVspsCXW9dLLMrGaO9_5RdXfOYTZ5aTxk9ZOpcp4UB2cyqEKVM38McWeuV7g/s220/MyPhoto.jpg'/></author><thr:total>0</thr:total></entry></feed>