<?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: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-4059713150518337557</id><updated>2011-07-30T10:51:51.509-07:00</updated><category term='Basics'/><category term='Android'/><title type='text'>Ashik Chollangi</title><subtitle type='html'>...for Android.                
This blog is not a fantasy blog, its dedicated to Android programming and getting tips on Android platform.All about Android..</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://forandroid.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://forandroid.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>ASH</name><uri>http://www.blogger.com/profile/11523297095605695023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>7</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4059713150518337557.post-2886950064100468788</id><published>2011-04-27T23:15:00.001-07:00</published><updated>2011-04-27T23:15:18.598-07:00</updated><title type='text'>Single Instance and Single Task</title><content type='html'>&lt;p align="justify"&gt;Run any application on an Android device and try various cases. In particular, note the following:&lt;br&gt;1)&amp;nbsp; Changing the screen orientation destroys and recreates the activity from scratch.&lt;br&gt;2)&amp;nbsp; Pressing the Home button pauses the activity, but does not destroy it.&lt;br&gt;3)&amp;nbsp; Pressing the Application icon might start a new instance of the activity, even if the&lt;br&gt;old one was not destroyed.&lt;br&gt;4)&amp;nbsp; Letting the screen sleep pauses the activity and the screen awakening resumes it.&lt;br&gt;(This is similar to taking an incoming phone call.)&lt;/p&gt; &lt;p align="justify"&gt;&amp;nbsp; &lt;p align="justify"&gt;As an application is navigated away from and launched again, it can lead to multiple instances of the activity on the device. Eventually the redundant instance of the activity is killed to free up memory, but in the meantime, it can lead to odd situations.To avoid these, the developer can control this behavior for each activity in the AndroidManifest. To ensure only one instance of the activity runs on the device, specify the following in an activity element that has the MAIN and LAUNCHER intent filters:&lt;/p&gt; &lt;p align="justify"&gt;android:launchMode="singleInstance"&lt;/p&gt; &lt;p align="justify"&gt;This keeps a single instance of each activity in a task at all times. In addition, any child activity is launched as its own task.To constrain even further to only have a single task for all activities of an application, use the following:&lt;/p&gt; &lt;p align="justify"&gt;android:launchMode="singleTask"&lt;/p&gt; &lt;p align="justify"&gt;This allows the activities to share information easily as the same task.In addition, it might be desirable to retain the task state, regardless of how a user navigates to the activity. For example, if a user leaves the application and relaunches it later, the default behavior often resets the task to its initial state.To ensure the user always returns to the task in its last state, specify the following in the activity element of the root activity of a task:&lt;/p&gt; &lt;p align="justify"&gt;android:alwaysRetainTaskState="true"&lt;/p&gt; &lt;p align="justify"&gt;This is the best way to control the memory utilization for the app as these days its completely multi-tasking!!!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4059713150518337557-2886950064100468788?l=forandroid.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forandroid.blogspot.com/feeds/2886950064100468788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forandroid.blogspot.com/2011/04/single-instance-and-single-task.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/2886950064100468788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/2886950064100468788'/><link rel='alternate' type='text/html' href='http://forandroid.blogspot.com/2011/04/single-instance-and-single-task.html' title='Single Instance and Single Task'/><author><name>ASH</name><uri>http://www.blogger.com/profile/11523297095605695023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4059713150518337557.post-4500767597994118380</id><published>2010-09-02T12:15:00.001-07:00</published><updated>2010-09-02T12:15:41.125-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Basics'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title type='text'>Android Basics-3(Dynamic views)</title><content type='html'>&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="justify"&gt;This is a very small tutorial and I want to cut this tutorial short as it just needs very minute but important understanding.&lt;/p&gt; &lt;p align="justify"&gt;In any new Android Project it can be seen in src/[filename].java that there is setContentView(R.layout.main) function being called automatically by the Eclipse IDE. In main.xml some UI elements are created and then are added to the Mobile screen by using this function, this means these(UI elements in main.xml) things are done/created before in the mobile RAM/cache and&amp;nbsp; then they are brought on mobile screen.If U completed&amp;nbsp; my previous &lt;a href="http://forandroid.blogspot.com/2010/08/android-basics-2-activity-and-intents.html"&gt;Android basic tutorial&lt;/a&gt;, its clear that importing UI elements from an xml file by “R.layout.main” is good but nothing is done visually on the screen.When U had&amp;nbsp; clicked the button there is just new Activity coming over with its own set of xml elements.Of course, there is logic/IQ(by intents) part when I click the button but still I can’t see anything visually changing in the present activity.Have U got my point?? In my previous tutorial, I used 2 activities and I clicked button to get in to other activity. Nothing is changed in a particular activity visually??Its just loading and finishing.Now lets change this a bit, I’ll enter some details and I want to print it right in that activity, no other activity or service should take the input data, means I want to change the view in one activity!..&lt;/p&gt; &lt;p align="justify"&gt;This sort of changing view in a activity is like adding dynamic content visually to the application.My previous tutorial is just a complete static visual tutorial.so, lets start the building a slightly dynamic tutorial. In this tutorial I want to Enter some word either it be a Name, Place, Thing or Animal and then when I click a button I want to display it . Thats it, roll over..&lt;/p&gt; &lt;p align="justify"&gt;create a new project with ur own project name, activity name,package name, avd target etc..overwrite contents of file src/[project name].java with the code showsn below&lt;/p&gt;&lt;pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  1: package com.android.printName;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  2: &lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  3: import android.app.Activity;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  4: import android.os.Bundle;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  5: import android.view.View;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  6: import android.view.View.OnClickListener;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  7: import android.widget.Button;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  8: import android.widget.EditText;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt;  9: import android.widget.TextView;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 10: import android.widget.Toast;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 11: &lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 12: &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; PrintName extends Activity {&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 13:     &lt;span style="color: #008000"&gt;/** Called when the activity is first created. */&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 14: 	TextView nameop;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 15: 	Button submit;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 16: 	EditText nameip;	&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 17: 	&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 18:     @Override&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 19:     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; onCreate(Bundle savedInstanceState) {&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 20:         super.onCreate(savedInstanceState);&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 21:         setContentView(R.layout.main);&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 22:     &lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 23:         nameop=(TextView)&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.findViewById(R.id.nameop);&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 24:         nameip=(EditText)&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.findViewById(R.id.nameip);&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 25:         submit = (Button)&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.findViewById(R.id.button);&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 26:                 &lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 27:         submit.setOnClickListener(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Button.OnClickListener() {&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 28: 			&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 29: 			&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; onClick(View v) {&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 30: 				&lt;span style="color: #008000"&gt;// TODO Auto-generated method stub&lt;/span&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 31: 				String name = nameip.getText().toString();&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 32: 		    	nameop.setText("&lt;span style="color: #8b0000"&gt;Your name is &lt;/span&gt;"+name);&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 33: 		    	&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 34: 		    	Toast.makeText(getApplicationContext(), "&lt;span style="color: #8b0000"&gt;Your name is &lt;/span&gt;"+name, Toast.LENGTH_SHORT).show();&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 35: 			}&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 36: 		});&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 37:     }&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 13px"&gt; 38: }&lt;span style="color: #008000"&gt;//end of printname class&lt;/span&gt;&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p align="justify"&gt;So what U find difficult here?? forget import statements they are done by Eclipse itself! I have nameip, nameop and a button. A String can be taken as input by using EditText UI element, Opuput is a TextVIew element and while loading this app for first time the String on TextView is nothing,just a null.But, when I click a button, I want to update the given string form EditText to be as output on Textview.Toast is just like a bread toaster on the screen, it makes a small portion of the screen toasted with the string provided.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;Update the main.xml with the following snippets&lt;/p&gt;&lt;pre class="csharpcode"&gt;&amp;lt;?xml version=&lt;span class="str"&gt;"1.0"&lt;/span&gt; encoding=&lt;span class="str"&gt;"utf-8"&lt;/span&gt;?&amp;gt;&lt;br /&gt;&amp;lt;AbsoluteLayout&lt;br /&gt;android:id=&lt;span class="str"&gt;"@+id/widget0"&lt;/span&gt;&lt;br /&gt;android:layout_width=&lt;span class="str"&gt;"fill_parent"&lt;/span&gt;&lt;br /&gt;android:layout_height=&lt;span class="str"&gt;"fill_parent"&lt;/span&gt;&lt;br /&gt;xmlns:android=&lt;span class="str"&gt;"http://schemas.android.com/apk/res/android"&lt;/span&gt;&lt;br /&gt;&amp;gt;&lt;br /&gt;&amp;lt;TableLayout&lt;br /&gt;android:id=&lt;span class="str"&gt;"@+id/widget28"&lt;/span&gt;&lt;br /&gt;android:layout_width=&lt;span class="str"&gt;"wrap_content"&lt;/span&gt;&lt;br /&gt;android:layout_height=&lt;span class="str"&gt;"wrap_content"&lt;/span&gt;&lt;br /&gt;android:orientation=&lt;span class="str"&gt;"vertical"&lt;/span&gt;&lt;br /&gt;android:layout_x=&lt;span class="str"&gt;"2px"&lt;/span&gt;&lt;br /&gt;android:layout_y=&lt;span class="str"&gt;"50px"&lt;/span&gt;&lt;br /&gt;&amp;gt;&lt;br /&gt;&amp;lt;TableRow&lt;br /&gt;android:id=&lt;span class="str"&gt;"@+id/widget33"&lt;/span&gt;&lt;br /&gt;android:layout_width=&lt;span class="str"&gt;"fill_parent"&lt;/span&gt;&lt;br /&gt;android:layout_height=&lt;span class="str"&gt;"wrap_content"&lt;/span&gt;&lt;br /&gt;android:orientation=&lt;span class="str"&gt;"horizontal"&lt;/span&gt;&lt;br /&gt;&amp;gt;&lt;br /&gt;&amp;lt;Button&lt;br /&gt;android:id=&lt;span class="str"&gt;"@+id/button"&lt;/span&gt;&lt;br /&gt;android:layout_width=&lt;span class="str"&gt;"wrap_content"&lt;/span&gt;&lt;br /&gt;android:layout_height=&lt;span class="str"&gt;"wrap_content"&lt;/span&gt;&lt;br /&gt;android:text=&lt;span class="str"&gt;"Name"&lt;/span&gt;&lt;br /&gt;&amp;gt;&lt;br /&gt;&amp;lt;/Button&amp;gt;&lt;br /&gt;&amp;lt;EditText&lt;br /&gt;android:id=&lt;span class="str"&gt;"@+id/nameip"&lt;/span&gt;&lt;br /&gt;android:layout_width=&lt;span class="str"&gt;"250px"&lt;/span&gt;&lt;br /&gt;android:layout_height=&lt;span class="str"&gt;"wrap_content"&lt;/span&gt;&lt;br /&gt;android:textSize=&lt;span class="str"&gt;"18sp"&lt;/span&gt;&lt;br /&gt;&amp;gt;&lt;br /&gt;&amp;lt;/EditText&amp;gt;&lt;br /&gt;&amp;lt;/TableRow&amp;gt;&lt;br /&gt;&amp;lt;/TableLayout&amp;gt;&lt;br /&gt;&amp;lt;TextView&lt;br /&gt;android:id=&lt;span class="str"&gt;"@+id/nameop"&lt;/span&gt;&lt;br /&gt;android:layout_width=&lt;span class="str"&gt;"wrap_content"&lt;/span&gt;&lt;br /&gt;android:layout_height=&lt;span class="str"&gt;"wrap_content"&lt;/span&gt;&lt;br /&gt;android:layout_x=&lt;span class="str"&gt;"25px"&lt;/span&gt;&lt;br /&gt;android:layout_y=&lt;span class="str"&gt;"137px"&lt;/span&gt;&lt;br /&gt;&amp;gt;&lt;br /&gt;&amp;lt;/TextView&amp;gt;&lt;br /&gt;&amp;lt;/AbsoluteLayout&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;As I said, this is just a tutorial and We need to go beyond.. To complete this tutorial some tasks must be done individually. ;)&lt;/p&gt;&lt;br /&gt;&lt;p&gt;1) Know everything about RadioGroup and Radio buttons, Make one RadioGroup for orientation and other RadioGroup for gravity.See the Image given carefully and find out exactly on how this can be done&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_BRdYykJEBcc/TH_30MjoLHI/AAAAAAAAA7k/3mi-i3ScxPQ/s1600-h/image%5B3%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/_BRdYykJEBcc/TH_31KujLDI/AAAAAAAAA7o/Lk2W94DPj0c/image_thumb%5B1%5D.png?imgmax=800" width="276" height="405"&gt;&lt;/a&gt; &lt;a href="http://lh5.ggpht.com/_BRdYykJEBcc/TH_31wQOu9I/AAAAAAAAA7s/tmD80UvgFdM/s1600-h/image%5B7%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_BRdYykJEBcc/TH_321mr1rI/AAAAAAAAA7w/LJI8u4RSm80/image_thumb%5B3%5D.png?imgmax=800" width="273" height="403"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Top two RadioButtons are part of orientation and bottom three RadioButtons are part of gravity.I like this program because it just uses if-else statements :) Learn complete RadioGroup info on Net or just browse over through android.widget.RadioGroup library function and Macros..&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Hope U enjoyed this tutorial and feel free to get helping hand from me, have a nice day.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4059713150518337557-4500767597994118380?l=forandroid.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forandroid.blogspot.com/feeds/4500767597994118380/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forandroid.blogspot.com/2010/09/android-basics-3dynamic-views.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/4500767597994118380'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/4500767597994118380'/><link rel='alternate' type='text/html' href='http://forandroid.blogspot.com/2010/09/android-basics-3dynamic-views.html' title='Android Basics-3(Dynamic views)'/><author><name>ASH</name><uri>http://www.blogger.com/profile/11523297095605695023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_BRdYykJEBcc/TH_31KujLDI/AAAAAAAAA7o/Lk2W94DPj0c/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4059713150518337557.post-5598642243056654815</id><published>2010-08-30T05:19:00.001-07:00</published><updated>2010-08-30T05:36:33.394-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Basics'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title type='text'>Android Basics-2 (Activity and Intents)</title><content type='html'>&lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="justify"&gt;Activity is the complete thing which U see on the complete screen.It could be anything on the screen like Buttons, Edittext boxes,Texts, Radio Buttons, lists, etc… are all part of Activity.So Activity is like complete thing which is running presently on the screen.&lt;/p&gt; &lt;p align="justify"&gt;&amp;nbsp;&lt;/p&gt; &lt;p align="justify"&gt;Lets try with an example, I’ll explain everyline after the code along with the xml file.The Objective of this Android Project is to switch between 2 activities on click of a button.&lt;/p&gt; &lt;blockquote&gt; &lt;p align="justify"&gt;In Eclipse, Simply create new Android project with name ‘SwitchActivity’, project name as ‘com.android.switchact’, activity with ‘SwitchingActivities’. Now override the java file in src/SwitchingActivities.java with&lt;/p&gt;&lt;/blockquote&gt; &lt;div align="justify"&gt;&lt;pre class="csharpcode"&gt;package com.android.switchact;&lt;br /&gt;&lt;br /&gt;import android.app.Activity;&lt;br /&gt;import android.content.Intent;&lt;br /&gt;import android.os.Bundle;&lt;br /&gt;import android.view.View;&lt;br /&gt;import android.view.View.OnClickListener;&lt;br /&gt;import android.widget.Button;&lt;br /&gt;import android.widget.TextView;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; SwitchingActivities extends Activity {&lt;br /&gt;    /** Called &lt;span class="kwrd"&gt;when&lt;/span&gt; the activity &lt;span class="kwrd"&gt;is&lt;/span&gt; first created. */&lt;br /&gt;    @Override&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; void onCreate(Bundle savedInstanceState) {&lt;br /&gt;        super.onCreate(savedInstanceState);&lt;br /&gt;        setContentView(R.layout.main);&lt;br /&gt;        TextView text1 = (TextView)findViewById(R.id.text1);&lt;br /&gt;        Button &lt;span class="kwrd"&gt;next&lt;/span&gt; = (Button)findViewById(R.id.&lt;span class="kwrd"&gt;next&lt;/span&gt;);&lt;br /&gt;        &lt;span class="kwrd"&gt;next&lt;/span&gt;.setOnClickListener(&lt;span class="kwrd"&gt;new&lt;/span&gt; View.OnClickListener() {&lt;br /&gt;            &lt;br /&gt;            @Override&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; void onClick(View v) {&lt;br /&gt;                // TODO &lt;span class="kwrd"&gt;Auto&lt;/span&gt;-generated method stub&lt;br /&gt;                Intent i = &lt;span class="kwrd"&gt;new&lt;/span&gt; Intent(v.getContext(),activity2.&lt;span class="kwrd"&gt;class&lt;/span&gt;);&lt;br /&gt;                startActivity(i);&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;        }&lt;br /&gt;    &lt;br /&gt;        &lt;br /&gt;}//&lt;span class="kwrd"&gt;end&lt;/span&gt; of &lt;span class="kwrd"&gt;class&lt;/span&gt; Swithchign activities&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Now lets take the res/Layout/main.xml file,override the whole content of main.xml file with the following code&lt;/p&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;="utf-8"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TableLayout&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:id&lt;/span&gt;&lt;span class="kwrd"&gt;="@+id/widget47"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_width&lt;/span&gt;&lt;span class="kwrd"&gt;="fill_parent"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_height&lt;/span&gt;&lt;span class="kwrd"&gt;="fill_parent"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="vertical"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;xmlns:android&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.android.com/apk/res/android"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TableRow&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:id&lt;/span&gt;&lt;span class="kwrd"&gt;="@+id/widget48"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_width&lt;/span&gt;&lt;span class="kwrd"&gt;="fill_parent"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_height&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="horizontal"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextView&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:id&lt;/span&gt;&lt;span class="kwrd"&gt;="@+id/text1"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_width&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_height&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:text&lt;/span&gt;&lt;span class="kwrd"&gt;="In Activity1"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TextView&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:id&lt;/span&gt;&lt;span class="kwrd"&gt;="@+id/next"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_width&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_height&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:text&lt;/span&gt;&lt;span class="kwrd"&gt;="next"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TableRow&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TableLayout&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Please look at this XML file carefully, its needed .&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;First lets get in to this main.XML file..&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_BRdYykJEBcc/THuhq9l1Z4I/AAAAAAAAA7M/jphUZKc-jng/s1600-h/image%5B4%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_BRdYykJEBcc/THuhrlXPvSI/AAAAAAAAA7Q/ebLP_ptzuiI/image_thumb%5B2%5D.png?imgmax=800" width="526" height="283"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;I’ll specify what I was thinking to make on the screen.In one Activity,I want to make table on the screen with a text specifying in which Activity the present Screen is in and a Button in that table to switch between activities, when clicked.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;There are different types of layouts in Android.TableLayout, RelativeLayout, LinearLayout etc..I recommend to know about these different types of layouts. So as this is a table there must be some Rows and Columns. Interestingly there is a &amp;lt;TableRow&amp;gt; tag in XML can be utilized as a Row for TableLayout.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;We can embed any number of things in this TableRow depending on the screen size.Lets take one TableRow and add one TextView element with String “Activity 1”. Then add one Button with text ”next” and &lt;strong&gt;I want to switch to other activity with this Button&lt;/strong&gt;. Now, If U look closely in the XML code there are some parameters called as layout_width and layout_height for each item. We need to specify Height and Width of each element as Mobile screen is limited.I asked TableLayout to “fill_parent” in both Height and Width for which it has to fill to its boundaries, the Whole screen.Next I added one TableRow saying it to wrap(“wrap_content”) its height and fill(“fill_parent”) its width completely to the table enough to represent the elements in it, as here a TextView and a Button.If I hadn’t said to wrap the width of TextView it will occupy the whole TableRow, a row filled with only one element, then I cannot add a Button to it.Thats why I said to wrap(“wrap_content”) the width of TextView according to the size of text in it. Then I added Button in TableRow an also wrapped it as I don’t want to mess with its size.&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;p align="justify"&gt;In SwitchingActivities.java, its class extends Activity means this java file can run as an Activity and we want to do that with command &lt;/p&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;pre class="csharpcode"&gt;setContentView(R.layout.main);&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;This command will run/bring the whole User Interface or Graphics in main.xml(R.layout.main is an Id to main.xml file) on the screen of Emulator.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;Here ‘R.layout.main’ specifies to load the content of main.xml in layout folder in R.java file.So, where is this R.java and what it is?? R.java is like a registry file which has all id’s of all the elements in res folder.Id’s are nothing but just integers associated to the resources like Buttons, Images, Strings, TextViews, EditTexts, XML files etc..Each resource has different Id. &lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;In any Android Project there are 2 things, Front-end and back-end. Front-end is like complete graphics or UI of the activity which we do it in XML files(in Java also it can be done but its painstaking).Back-end is like the logic or IQ part of the application which we implement using java code.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;We have XML component but we need to use it in this java code as this java code is the logic part and so we need to link our UI and logic to make application perfect. this is done by the code&lt;/p&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;pre class="csharpcode"&gt;Button next = (Button)findViewById(R.id.next);&lt;br /&gt;        next.setOnClickListener(&lt;span class="kwrd"&gt;new&lt;/span&gt; View.OnClickListener() {&lt;br /&gt;            &lt;br /&gt;            &lt;span class="preproc"&gt;@Override&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; onClick(View v) {&lt;br /&gt;                &lt;span class="rem"&gt;// TODO Auto-generated method stub&lt;/span&gt;&lt;br /&gt;                Intent i = &lt;span class="kwrd"&gt;new&lt;/span&gt; Intent(v.getContext(),activity2.&lt;span class="kwrd"&gt;class&lt;/span&gt;);&lt;br /&gt;                startActivity(i);&lt;br /&gt;            }&lt;br /&gt;        });&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align="justify"&gt;We linked java Button element with the Button in main.xml file by its ID in R.java.Implemented a onClickListener() to it.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;In main.xml we have a Button with id “next” and TextView with id “text1” in this activity.When this Activity is running there will be a text specifying “In Activity 1” and a Button with text “Next” on it. But I want to run other activity when I click this ‘Next’.So, My activity should be watching this button from when it had started and when ‘next’ got pressed/clicked it has to switch over to other activity and this can be accomplished by listeners.Listeners are the things which listen and when appropriate click is done it starts&amp;nbsp; working.We have onClickListener() function for Buttons, MotionEvent for Touch etc.. &lt;strong&gt;Other activity is started by using intents.Intent specifies what operation must be performed&lt;/strong&gt;.So, I used Intent to start a new Activity using code shown below.&lt;/p&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;pre class="csharpcode"&gt;Intent i = &lt;span class="kwrd"&gt;new&lt;/span&gt; Intent(v.getContext(),activity2.&lt;span class="kwrd"&gt;class&lt;/span&gt;);&lt;br /&gt;                startActivity(i);&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;p align="justify"&gt;New Activity also needs similar structure of UI, an XML file and a java Class, which must extend activity.so create new class by right-clicking on src folder and click new, name it as&amp;nbsp; ‘activity2’ .Make the following code for activity2.java.&lt;/p&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;pre class="csharpcode"&gt;package com.android.switchact;&lt;br /&gt;&lt;br /&gt;import android.app.Activity;&lt;br /&gt;import android.content.Intent;&lt;br /&gt;import android.os.Bundle;&lt;br /&gt;import android.view.View;&lt;br /&gt;import android.view.View.OnClickListener;&lt;br /&gt;import android.widget.Button;&lt;br /&gt;import android.widget.TextView;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; activity2 extends Activity {&lt;br /&gt;    &lt;span class="rem"&gt;/** Called when the activity is first created. */&lt;/span&gt;&lt;br /&gt;    &lt;span class="preproc"&gt;@Override&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; onCreate(Bundle savedInstanceState) {&lt;br /&gt;        super.onCreate(savedInstanceState);&lt;br /&gt;        setContentView(R.layout.activity2);&lt;br /&gt;        TextView text2 = (TextView)findViewById(R.id.text2);&lt;br /&gt;        Button previous = (Button)findViewById(R.id.previous);&lt;br /&gt;        previous.setOnClickListener(&lt;span class="kwrd"&gt;new&lt;/span&gt; View.OnClickListener() {&lt;br /&gt;            &lt;br /&gt;            &lt;span class="preproc"&gt;@Override&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; onClick(View v) {&lt;br /&gt;                &lt;span class="rem"&gt;// TODO Auto-generated method stub&lt;/span&gt;&lt;br /&gt;                  Intent i = &lt;span class="kwrd"&gt;new&lt;/span&gt; Intent();&lt;br /&gt;                finish();&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;        }&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;}&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Here please don’t write the import statements. Ofcourse, U’ll get error in Eclipse as it can’t find the related functions but click on the error and it automatically displays why error occurred and will Add import statements itself.There are lot of shortcuts in Eclipse. just while typing any function type first 2 letters and hit ctrl+space&amp;nbsp; it gives the list of similar functions from its libraries.Know shortcuts and complete the work soon, Don’t type everything as Eclipse IDE can do more than half of the coding work. :)&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;In activity2.java there is code &lt;br&gt;&lt;/p&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;setContentView(R.layout.activity2);&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;This loads the UI of activity2.xml, which means each activity needs an XML or UI elements to run or else there will be no display or I don’t know, it might give an error also ;)..create new Android XML file in res/layout folder, name it as “activity2.xml” . Open the activity2.xml file and override it with the following xml components..&lt;/p&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;="utf-8"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TableLayout&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:id&lt;/span&gt;&lt;span class="kwrd"&gt;="@+id/widget47"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_width&lt;/span&gt;&lt;span class="kwrd"&gt;="fill_parent"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_height&lt;/span&gt;&lt;span class="kwrd"&gt;="fill_parent"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="vertical"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;xmlns:android&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.android.com/apk/res/android"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TableRow&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:id&lt;/span&gt;&lt;span class="kwrd"&gt;="@+id/widget48"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_width&lt;/span&gt;&lt;span class="kwrd"&gt;="fill_parent"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_height&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:orientation&lt;/span&gt;&lt;span class="kwrd"&gt;="horizontal"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;TextView&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:id&lt;/span&gt;&lt;span class="kwrd"&gt;="@+id/text2"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_width&lt;/span&gt;&lt;span class="kwrd"&gt;="250px"&amp;lt;!—-this is the way to write comment in xml --&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;&amp;lt;!--here 250px means 250 pixels of screem -–&amp;gt;&lt;/span&gt;&lt;span class="attr"&gt;android:layout_height&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt; &lt;span class="attr"&gt;android:text&lt;/span&gt;&lt;span class="kwrd"&gt;="In Activity2"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TextView&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:id&lt;/span&gt;&lt;span class="kwrd"&gt;="@+id/previous"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_width&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:layout_height&lt;/span&gt;&lt;span class="kwrd"&gt;="wrap_content"&lt;/span&gt;&lt;br /&gt;&lt;span class="attr"&gt;android:text&lt;/span&gt;&lt;span class="kwrd"&gt;="Previous"&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Button&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TableRow&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;TableLayout&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;If U take a closer look, its very much similar to the main.xml but look steeply I changed the Id’s, text and&amp;nbsp; layout parameters of TextView. If there is no change of Id’s then we get error as all these elements will be part of R.java(Registry) and as there is a duplicate item it throws error.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;Now I’ll say what I wanted to do with this Activity.When I click the button in this activity, this activity should close itself and come back to previous activity. Thats why I named the button as Previous. See the TextView, its text is “In Activity 2” just to know that we are in other activity.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;here command &lt;/p&gt;&lt;br /&gt;&lt;div align="justify"&gt;&lt;pre class="csharpcode"&gt;finish();&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;is to shutdown this activity or else we can call other activity from this one just by using Intents.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;When U run this project as Android Application U must see this screen&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;a href="http://lh6.ggpht.com/_BRdYykJEBcc/THuhspL08KI/AAAAAAAAA7U/rGCTz6fbmt8/s1600-h/image%5B19%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://lh6.ggpht.com/_BRdYykJEBcc/THuhtS6BNLI/AAAAAAAAA7Y/NPYPLH4_a3k/image_thumb%5B11%5D.png?imgmax=800" width="259" height="381"&gt;&lt;/a&gt; &lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt; and after clicking next button U must see other activity. Check out the text displayed changes on the screen according to the click of these buttons from “in Activity 1” to “In Activity 2” and viceversa.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;&lt;a href="http://lh4.ggpht.com/_BRdYykJEBcc/THuhtx3lQwI/AAAAAAAAA7c/R8RN6lZIc5o/s1600-h/image%5B18%5D.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://lh6.ggpht.com/_BRdYykJEBcc/THuhuvpUhmI/AAAAAAAAA7g/emLvv4evE8w/image_thumb%5B10%5D.png?imgmax=800" width="254" height="377"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;Lastly U need to know about Android Manifest file in Your Project.This is the file which specifies what activities are there in your app what permissions do they need like dial numbers, get contacts, access http, access maps,access gps etc.. This file can also include any user-libraries for custom made app of our own libraries.This file must contain list of all activities or else there will be “Force close” error on emulator.To specify that there is an activity callled as “activity2.java” change the AndroidManifest.xml according to code shown below&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;?&lt;/span&gt;&lt;span class="html"&gt;xml&lt;/span&gt; &lt;span class="attr"&gt;version&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt; &lt;span class="attr"&gt;encoding&lt;/span&gt;&lt;span class="kwrd"&gt;="utf-8"&lt;/span&gt;?&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;manifest&lt;/span&gt; &lt;span class="attr"&gt;xmlns:android&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.android.com/apk/res/android"&lt;/span&gt;&lt;br /&gt;      &lt;span class="attr"&gt;package&lt;/span&gt;&lt;span class="kwrd"&gt;="com.android.switchact"&lt;/span&gt;&lt;br /&gt;      &lt;span class="attr"&gt;android:versionCode&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt;&lt;br /&gt;      &lt;span class="attr"&gt;android:versionName&lt;/span&gt;&lt;span class="kwrd"&gt;="1.0"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;application&lt;/span&gt; &lt;span class="attr"&gt;android:icon&lt;/span&gt;&lt;span class="kwrd"&gt;="@drawable/icon"&lt;/span&gt; &lt;span class="attr"&gt;android:label&lt;/span&gt;&lt;span class="kwrd"&gt;="@string/app_name"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;activity&lt;/span&gt; &lt;span class="attr"&gt;android:name&lt;/span&gt;&lt;span class="kwrd"&gt;=".SwitchingActivities"&lt;/span&gt;&lt;br /&gt;                  &lt;span class="attr"&gt;android:label&lt;/span&gt;&lt;span class="kwrd"&gt;="@string/app_name"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;intent-filter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;action&lt;/span&gt; &lt;span class="attr"&gt;android:name&lt;/span&gt;&lt;span class="kwrd"&gt;="android.intent.action.MAIN"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;                &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;category&lt;/span&gt; &lt;span class="attr"&gt;android:name&lt;/span&gt;&lt;span class="kwrd"&gt;="android.intent.category.LAUNCHER"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;intent-filter&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;activity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;activity&lt;/span&gt; &lt;span class="attr"&gt;android:name&lt;/span&gt;&lt;span class="kwrd"&gt;=".activity2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;activity&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;application&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;manifest&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt; &lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p align="justify"&gt;Hope U enjoyed this tutorial and got everybit of Activity. But, there is saying that if an application has too many activities application slows down accordingly,because they pile up on the stack reducing the RAM. &lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;Now , I want U&amp;nbsp; all to know this is just basics and We should not stop at basics there are couple of things to be done by U all. Just Google these concepts to complete the tasks&lt;/p&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;p align="justify"&gt;1) I want to pass a String data to and from both activities using bundle(Google this one) concept.just use functions like putExtras() to achieve this task.&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;2) Download DroidDraw from &lt;a title="http://www.droiddraw.org/" href="http://www.droiddraw.org/"&gt;http://www.droiddraw.org/&lt;/a&gt; ,this tool is considered as the best tool to make xml file, just follow the first 2 tutorials in this site. By this U‘ll understand that its very much easy to make UI components using XML.(By this tool there is no need to type the XML file just create it graphically) :D&lt;/p&gt;&lt;br /&gt;&lt;p align="justify"&gt;3) now Add other TableRow and add button to it,look out how the whole UI changes according to other TableRow. Do it in Droiddraw ;)&lt;/p&gt;&lt;/blockquote&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4059713150518337557-5598642243056654815?l=forandroid.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forandroid.blogspot.com/feeds/5598642243056654815/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forandroid.blogspot.com/2010/08/android-basics-2-activity-and-intents.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/5598642243056654815'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/5598642243056654815'/><link rel='alternate' type='text/html' href='http://forandroid.blogspot.com/2010/08/android-basics-2-activity-and-intents.html' title='Android Basics-2 (Activity and Intents)'/><author><name>ASH</name><uri>http://www.blogger.com/profile/11523297095605695023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_BRdYykJEBcc/THuhrlXPvSI/AAAAAAAAA7Q/ebLP_ptzuiI/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4059713150518337557.post-7148720574433181843</id><published>2010-08-30T01:27:00.001-07:00</published><updated>2010-08-30T01:27:15.529-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title type='text'>Common tasks for Android Developers</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Google knew that its very tough to get some minimum basics for Android development. They made a list of programming skills needed for basic developers to advance in depth later. So, these programming skills must be acquired by each and every Android Developer.&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;This list is at &lt;a title="http://developer.android.com/guide/appendix/faq/commontasks.html" href="http://developer.android.com/guide/appendix/faq/commontasks.html"&gt;http://developer.android.com/guide/appendix/faq/commontasks.html&lt;/a&gt; ..When an task on list is clicked some info on How to do that task&amp;nbsp; is given by showing some functions and some methods to complete it.&lt;/p&gt; &lt;p&gt;So, I will be posting all the info and code snippets to complete the task..&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4059713150518337557-7148720574433181843?l=forandroid.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forandroid.blogspot.com/feeds/7148720574433181843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forandroid.blogspot.com/2010/08/common-tasks-for-android-developers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/7148720574433181843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/7148720574433181843'/><link rel='alternate' type='text/html' href='http://forandroid.blogspot.com/2010/08/common-tasks-for-android-developers.html' title='Common tasks for Android Developers'/><author><name>ASH</name><uri>http://www.blogger.com/profile/11523297095605695023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4059713150518337557.post-8993898875036373671</id><published>2010-08-30T00:56:00.001-07:00</published><updated>2010-08-30T01:42:42.420-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Basics'/><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title type='text'>Android Basics –1 (LogCat)</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;When an App is run as Android Application the whole project will run on emulator as .apk file. in this apk file all the files, images, xml, java byte code will be packed. When a new Android Project is created a lot of files and folders are created.Res folder contains all the resources for Layout, Strings, images as Drawable which can be used by any part of the application. Layout folder contains all the XML files which describes the layout. String folder contains all the string resources which can be used in the app.However I want to say something which is beyond what books say. &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Whenever there is a runtime error the app in the Emulator just closes mostly saying “Force Close”. User cannot do anything in this situation except accept the error and click on “Force Close”. This sort of error occur manytimes in development of any app and Developers starts scratching their heads to find out what could be wrong in the code. In this situation I recommend to watch out Logcat. This is the tool which displays what's happening in the Emulator and whenever there is an an Error, Logcat clearly specifies the error by telling there was a “NullPointerExcepion” while accessing a particular function or “ArrayOutOfBoundException” at a particular line etc.. &lt;/p&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_BRdYykJEBcc/THtkJ10BdxI/AAAAAAAAA60/y4C4lUacgTg/s1600-h/image%5B3%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/_BRdYykJEBcc/THtkK2dlGsI/AAAAAAAAA64/TfwyvyOevs4/image_thumb%5B1%5D.png?imgmax=800" width="398" height="94"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;To access logcat u have to change the perspective from java to DDMS, then look a mid portion of the screen where it looks similar to the given image below&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;a href="http://lh5.ggpht.com/_BRdYykJEBcc/THtkLr2r4bI/AAAAAAAAA68/QmiPJrWTbSs/s1600-h/image%5B8%5D.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/_BRdYykJEBcc/THtkM0Vu64I/AAAAAAAAA7A/HMd-5e69fKo/image_thumb%5B4%5D.png?imgmax=800" width="408" height="326"&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;In this Logcat its easy to find any errors/ exceptions at runtime and even We can use this logcat as output rather than getting output in Emulator screen. To use logcat as output a funtion must be run in Java code and this function is &lt;/p&gt;&lt;pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;//Log.i(String tag, String message);done as following&lt;br /&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;&lt;/pre&gt;&lt;pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"&gt;Log.i("Hi"."Button Clicked");&lt;/pre&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Here when this line is run it displayed “Hi” under tab and “Button Clicked”&amp;nbsp; as message.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Hope U liked this basic understanding and please feel free to ask any doubts..&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4059713150518337557-8993898875036373671?l=forandroid.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forandroid.blogspot.com/feeds/8993898875036373671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forandroid.blogspot.com/2010/08/android-basics-1-logcat.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/8993898875036373671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/8993898875036373671'/><link rel='alternate' type='text/html' href='http://forandroid.blogspot.com/2010/08/android-basics-1-logcat.html' title='Android Basics –1 (LogCat)'/><author><name>ASH</name><uri>http://www.blogger.com/profile/11523297095605695023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_BRdYykJEBcc/THtkK2dlGsI/AAAAAAAAA64/TfwyvyOevs4/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4059713150518337557.post-8282370641518333983</id><published>2010-08-28T09:54:00.000-07:00</published><updated>2010-08-28T09:54:05.473-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Android'/><title type='text'>Requirements for Android</title><content type='html'>So, lets start what are the requirements needed for Android application development.&lt;br /&gt;&lt;div align="justify"&gt;1) Eclipse IDE: This is the IDE where Android apps will be written and compiled in an Emulator. Emulator is the virtual android device where the application code will be made to run/executed just as it could be in a real Mobile.But, in Eclipse Android Emulator is not provided, it just compiles the code and if found any errors it give a red cross. So, we must download Emulator to run the application.Eclipse by default doesn’t know anything about Android and so Google provided some Android Libraries(along with its own Tools) which can be included into Eclipse as an Environment to execute the code.Interestingly Google provides these Android libraries as Android SDK(Software Development KIT). This kit also includes the Emulator :) All in one shot..get Eclipse Galileo/Helios any version&amp;nbsp; at &lt;cite&gt;&lt;a href="http://www.eclipse.org/downloads/"&gt;www.eclipse.org/downloads/&lt;/a&gt;&lt;/cite&gt;&lt;/div&gt;2) Android SDK: As I said this SDK is the thing which has all the libraries needed for Android execution and also it has the Emulator to run the app as it runs in normal Android phone.Get Android SDK at the site given, &lt;a href="http://developer.android.com/sdk/index.html"&gt;http://developer.android.com/sdk/index.html&lt;/a&gt;. So now we have all the requirements needed Eclipse and Android SDK but as I said how does Eclipse can get all these SDK libraries in to it?? We need to link this SDK to Eclipse to start A new Android Project.&lt;br /&gt;3) This linking is done in Eclipse by its plug-ins.Plug-in is the thing just as a wire with a plug. Just like when we need to run a TV first We need to plug-in the TV cable to switchboard.Same as that We need a eclipse plug-in to show new perspective of compiling environment simply call it as Android Environment.This plug-in is called Android Development Tool(ADT). After Installing Eclipse goto Help –&amp;gt; Install new Software and type in - Work with&amp;nbsp; &lt;a href="http://www.blogger.com/%E2%80%9Chttps://dl-ssl.google.com/android/eclipse/%E2%80%9D"&gt;“https://dl-ssl.google.com/android/eclipse/”&lt;/a&gt; . Next just include all tools and complete the installation!!&lt;br /&gt;4) Unzip the Android SDK to any drive. Open Eclipse then window –&amp;gt; preferences –&amp;gt; Android ! Here browse the SDK location to the unzipped Android SDK folder. After this is done Eclipse loads all the libraries and must add a perspective called DDMS and also When U open new project there must be ‘New Android Project’ to select . If DDMS or ‘New Android Project’ doesn’t appear then linking Android to Eclipse failed, repeat again.&lt;br /&gt;5) So after making a ‘New Android Project’ and writing all the code where can we compile, we need an Emulator and to our interest Emulator is in SDK and We had linked this SDK to Eclipse. Simple We must be able to launch an Emulator from Eclipse to run the Android Projects.click Window –&amp;gt; Android SDK and AVD manager, before Going in this section U need to know some details about Android.&lt;br /&gt;&lt;blockquote&gt;Google bought Android company in 2002 and then they started this Android SDK version 1.0 in 2008. From here things went far beyond anyone could expect.Google started initiative of OHA(Open Handset Alliance) and manufacturers must be join this OHA to produce Android phones. Now there are more than 100 Mobile manufacturers in this OHA from Nokia, Samsung, Sony, LG, Dell, Kyocera, HTC etc…So things were like a competition, till 2009 only 2-3 Android phones(including Google nexus) were in the market but in early 2010 there was sudden splurge of Android phones and&amp;nbsp; Android SDK versions creating dilemma for Developers. From 2008 to 2010 different versions of Android SDK were released, from 1.0 –&amp;gt; 1.5 –&amp;gt; 1.6 –&amp;gt; 2.0 –&amp;gt; 2.1 –&amp;gt;2.2(mid of 2010)&amp;nbsp; were rolled out. The need to make such versions shows the way Android Source code evolved.So, in our SDK we will be having all these emulators from 1.0 to the latest one. Emulator is an AVD(Android Virtual Device).There are many manufacturers still developing Android Apps in SDK 1.5 and 1.6 versions like Dell with their mobile Aero. &lt;/blockquote&gt;So, when We need to compile the Android App we need an emulator and there are many versions of Emulator from 1.0 to 2.2(2.2 is the latest one). When window –&amp;gt; Android SDK and AVD manager is opened u’ll see this dilemma.Write a name of your choice select a Emulator version which is the latest one.For a normal developer 50 MB of SD card is more than sufficient.&lt;br /&gt;Skin is the thing which differs lot. There are many Android devices in the market ranging from mobiles to tablets. When developing apps for tablets we must have a emulator which is&amp;nbsp; quite relevant and appropriate to the real Device. There skin comes to picture, tablets have high resolution compared to normal Mobiles. To make such an Emulator just click resolution and type the numbers like 800 X 600 to get the screen equivalent to such resolution tablet.For normal mobile app development just use built-in skin. click create, then we get an new AVD where we can compile the Android apps. :) &lt;br /&gt;&lt;br /&gt;so we have all the needed things to compile Android apps and now just create new android project fill up the project name with “Hello World”, application name with “Hello Android”, package name with “com.android.hello”, sdk version to the appropriate version of AVD U just created and then Create Activity to “Hello Android”. now just right-click the project name in the left-side project explorer, wait a couple of minutes to send this project code to emulator. Then U can see “Hello World”&amp;nbsp; on the Emulator screen.Don’t get stumbled when U see different types of&amp;nbsp; files in your project.&lt;br /&gt;&lt;br /&gt;Hope U enjoyed this post. Pls ask questions if u get any doubts!!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4059713150518337557-8282370641518333983?l=forandroid.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forandroid.blogspot.com/feeds/8282370641518333983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forandroid.blogspot.com/2010/08/requirements-for-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/8282370641518333983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/8282370641518333983'/><link rel='alternate' type='text/html' href='http://forandroid.blogspot.com/2010/08/requirements-for-android.html' title='Requirements for Android'/><author><name>ASH</name><uri>http://www.blogger.com/profile/11523297095605695023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4059713150518337557.post-1071748246016618557</id><published>2010-08-27T23:36:00.001-07:00</published><updated>2010-08-27T23:36:06.217-07:00</updated><title type='text'>Welcome to Android</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;so Guys &amp;amp; Gals, this is my blog and I’ll be posting a lot about Android. If you are new to Android and want to be a perfect programmer for Android then pls follow this blog as I give a lot of stuff for delving inn..pls feel free to ask any doubts or any sort of questions to me at &lt;a href="mailto:ashikch@gmail.com"&gt;ashikch@gmail.com&lt;/a&gt; or just comment here and ill post appropriately..&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/4059713150518337557-1071748246016618557?l=forandroid.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://forandroid.blogspot.com/feeds/1071748246016618557/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://forandroid.blogspot.com/2010/08/welcome-to-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/1071748246016618557'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4059713150518337557/posts/default/1071748246016618557'/><link rel='alternate' type='text/html' href='http://forandroid.blogspot.com/2010/08/welcome-to-android.html' title='Welcome to Android'/><author><name>ASH</name><uri>http://www.blogger.com/profile/11523297095605695023</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
