SlideShare a Scribd company logo
1 
Android Introduction 
Hello World
Tutorial 
 http://developer.android.com/resources/t 
utorials/hello-world.html 
 http://mobiforge.com/developing/story/ge 
tting-started-with-android-development? 
dm_switcher=true 
2
Create a New Android Project 
 From Eclipse, select File > New > Android 
Project. 
 Fill in the project details with the following 
values: 
 Project name: HelloAndroid 
 Application name: Hello, Android 
 Package name: com.example.helloandroid (or 
your own private namespace) 
 Create Activity: HelloAndroid 
Click Finish 
3
4 
Create a New 
Android Project
Create a New Android Project 
 Project name - the name of the project 
 Package name - the name of the package. This 
name will be used as the package name in your 
Java files. Package name must be fully qualified. 
The convention is to use your company's domain 
name in reverse order 
 Activity name - the name of the activity in your 
Android application. In Android, think of an 
activity as a screen containing some actions, 
hence the name "activity" 
 Application name - the user-friendly name of the 
application that will be displayed in the 
Applications tab of the Android UI 
5
6 
Package Content 
All source code here Java code for our activity 
Generated Java code 
Helps link resources to 
Java code 
Layout of the activity 
Strings used in the 
program 
All non-code 
resources 
Android Manifest 
Images
the various fields when create a new 
Android project 
 First, the src folder contains your Java source files. The HelloAndroid.java 
file is the source file for the HelloAndroid activity you specified when you 
created the project earlier. 
 The R.java file is a special file generated by the ADT to keep track of all 
the names of views, constants, etc, used in your Android project. You 
should not modify the content of this file as its content is generated 
automatically by the ADT. 
 The Android Library contains a file named android.jar. This file contains all 
the classes that you would use to program an Android application. 
 The res folder contains all the resources used by your Android application. 
For example, the drawable folder contains a png image file that is used as 
the icon for your application. The layout folder contains an XML file used to 
represent the user interface of your Android application. The values folder 
contains an XML file used to store a list of string constants. 
 The AndroidManifest.xml file is an application configuration file that 
contains detailed information about your application, such as the number 
of activities you have in your application, the types of permissions your 
application needs, the version information of your application, and so on. 
7
8 
Run the Application 
 The Eclipse plugin makes it easy to run your applications: 
 Select Run > Run. 
 Select "Android Application".
9 
/res/layout/main.xml 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello" 
/> 
</LinearLayout>
10 
XML attributes 
 xmlns:android 
This is an XML namespace declaration that tells the Android 
tools that you are going to refer to common attributes 
defined in the Android namespace. The outermost tag in 
every Android layout file must have this attribute. 
 android:id 
This attribute assigns a unique identifier to the TextView 
element. You can use the assigned ID to reference this 
View from your source code or from other XML resource 
declarations. 
 android:layout_width 
This attribute defines how much of the available width on 
the screen this View should consume. In this case, it's the 
only View so you want it to take up the entire screen, which 
is what a value of "fill_parent" means.
11 
XML attributes 
 android:layout_height 
This is just like android:layout_width, except that it refers 
to available screen height. 
 android:text 
This sets the text that the TextView should display. In this 
example, you use a string resource instead of a hard-coded 
string value. The hello string is defined in the 
res/values/strings.xml file. This is the recommended 
practice for inserting strings to your application, because it 
makes the localization of your application to other 
languages graceful, without need to hard-code changes to 
the layout file.
/res/values/strings.xml 
 In Android, the UI of each activity is represented using various 
objects known as Views. You can create a view using code, or 
more simply through the use of an XML file. 
 In this case, the UI Is represented using an XML file. 
 The <TextView> element represents a text label on the screen 
while the <LinearLayout> element specifies how views should be 
arranged. 
 Notice that the <TextView> element has an attribute named 
12 
android:text with its value set to "@string/hello". 
 The @string/hello refers to the string named hello defined in the 
strings.xml file in the res/values folder. 
<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<string name="hello">Hello World, HelloAndroid!</string> 
<string name="app_name">HelloAndroid</string> 
</resources>
13 
Modify strings.xml 
<?xml version="1.0" encoding="utf-8"?> 
<resources> 
<string name="hello">Hello, Android! I am a string 
resource!</string> 
<string name="app_name">Hello, Android</string> 
</resources>
14 
Run it !
15 
Modify the main.xml 
 Let's now modify the main.xml file. Add the following <Button> element: 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="@string/hello" 
/> 
<Button 
android:id="@+id/btnClickMe" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Click Me!" 
/> 
</LinearLayout>
16 
Run it !
17 
Construct UI 
package com.example.helloandroid; 
import android.app.Activity; 
import android.os.Bundle; 
import android.widget.TextView; 
public class HelloAndroid extends Activity { 
/** Called when the activity is first created. */ 
@Override 
public void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
TextView tv = new TextView(this); 
tv.setText("Hello, Android"); 
setContentView(tv); 
} 
}
18 
Run it
19 
R class 
 In Eclipse, open the file named R.java (in the gen/ [Generated Java Files] folder). 
 The R.java file is a special file generated by the ADT to keep track of all the names of 
views, constants, etc, used in your Android project. You should not modify the 
content of this file as its content is generated automatically by the ADT 
package com.example.helloandroid; 
public final class R { 
public static final class attr { 
} 
public static final class drawable { 
public static final int icon=0x7f020000; 
} 
public static final class id { 
public static final int textview=0x7f050000; 
} 
public static final class layout { 
public static final int main=0x7f030000; 
} 
public static final class string { 
public static final int app_name=0x7f040001; 
public static final int hello=0x7f040000; 
} 
}
AndroidManifest.xml 
 The AndroidManifest.xml file is an application configuration file 
that contains detailed information about your application, such as 
the number of activities you have in your application, the types of 
permissions your application needs, the version information of 
your application, and so on. 
20 
<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.helloandroid" 
android:versionCode="1" 
android:versionName="1.0"> 
<application android:icon="@drawable/icon" android:label="@string/app_name"> 
<activity android:name=".HelloAndroid" 
android:label="@string/app_name"> 
<intent-filter> 
<action android:name="android.intent.action.MAIN" /> 
<category android:name="android.intent.category.LAUNCHER" /> 
</intent-filter> 
</activity> 
</application> 
</manifest>

More Related Content

PPTX
Introduction To Google Android (Ft Rohan Bomle)
PPTX
Android Layout.pptx
ODP
Разработка приложений для Android Honeycomb: ActionBar & Fragments
PDF
Android application development workshop day1
PPTX
Android Tutorials - Powering with Selection Widget
PPT
android training_material ravy ramio
PDF
SAX - Android Development
ODP
Day seven
Introduction To Google Android (Ft Rohan Bomle)
Android Layout.pptx
Разработка приложений для Android Honeycomb: ActionBar & Fragments
Android application development workshop day1
Android Tutorials - Powering with Selection Widget
android training_material ravy ramio
SAX - Android Development
Day seven

What's hot (20)

PDF
Android Lab
ODP
Session 2- day 3
PDF
Training Session 2 - Day 2
PDF
How to build integrated, professional enterprise-grade cross-platform mobile ...
PPT
Getting started with android dev and test perspective
PPT
Android Applications Development
PPTX
Titanium Studio [Updated - 18/12/2011]
PDF
Android Development: Build Android App from Scratch
PDF
Android appwidget
PPTX
Write an application that draws basic graphical primitives.pptx
DOCX
Creation of simple application using - step by step
PPTX
Using Page Objects
PPT
OpenSocial Intro
DOC
Demystifying Keyword Driven Using Watir
PDF
Android studio
PPT
Google Android
KEY
Android Workshop
PPTX
Android Life Cycle
PDF
Android ui layouts ,cntls,webservices examples codes
PDF
Android Test Automation Workshop
Android Lab
Session 2- day 3
Training Session 2 - Day 2
How to build integrated, professional enterprise-grade cross-platform mobile ...
Getting started with android dev and test perspective
Android Applications Development
Titanium Studio [Updated - 18/12/2011]
Android Development: Build Android App from Scratch
Android appwidget
Write an application that draws basic graphical primitives.pptx
Creation of simple application using - step by step
Using Page Objects
OpenSocial Intro
Demystifying Keyword Driven Using Watir
Android studio
Google Android
Android Workshop
Android Life Cycle
Android ui layouts ,cntls,webservices examples codes
Android Test Automation Workshop
Ad

Viewers also liked (20)

DOC
CV_Zhalyn_English2
PPT
Restaurant cleaner kpi
PPT
Restaurant expeditor kpi
PPT
Restaurant runner kpi
PPT
Restaurant trainer kpi
PPT
Risk analyst kpi
PPT
Restaurant crew kpi
PPT
Restaurants server kpi
ODP
Synapse india reviews on mobile devices
PPT
Restaurant greeter kpi
PPT
Synapse india reviews on drupal 7 entities (stanford)
PPT
Synapse india reviews on drupal intro
PPT
Restaurant associate kpi
PPT
Restaurant bookkeeper kpi
PPT
Restaurant administrator kpi
PPT
Restaurant assistant kpi
PPT
Restaurant bartender kpi
PPT
Restaurant busboy kpi
PPT
Risk manager kpi
ODP
Synapseindia reviews.odp.
CV_Zhalyn_English2
Restaurant cleaner kpi
Restaurant expeditor kpi
Restaurant runner kpi
Restaurant trainer kpi
Risk analyst kpi
Restaurant crew kpi
Restaurants server kpi
Synapse india reviews on mobile devices
Restaurant greeter kpi
Synapse india reviews on drupal 7 entities (stanford)
Synapse india reviews on drupal intro
Restaurant associate kpi
Restaurant bookkeeper kpi
Restaurant administrator kpi
Restaurant assistant kpi
Restaurant bartender kpi
Restaurant busboy kpi
Risk manager kpi
Synapseindia reviews.odp.
Ad

Similar to Synapseindia android apps introduction hello world (20)

KEY
Android momobxl
PPT
Lec005 android start_program
PDF
Android stepbystep
PPTX
Project anatomy & hello world
PDF
Android application development
PDF
Android stepbystep
PDF
Android session 1
PPTX
Android Development project
PPTX
Android Development Made Easy - With Sample Project
PPTX
Introduction & App Structure
ODP
Android introduction
PDF
Android Application Development - Level 1
PPTX
Android Development for Beginners with Sample Project - Day 1
PPTX
Android development session
PPTX
Android
PPTX
Android Basic
PPTX
More on Application Structure
PPT
Intro to Android Programming
PPT
Unit 2 in environment science and technology
PPT
Getting started with android studio
Android momobxl
Lec005 android start_program
Android stepbystep
Project anatomy & hello world
Android application development
Android stepbystep
Android session 1
Android Development project
Android Development Made Easy - With Sample Project
Introduction & App Structure
Android introduction
Android Application Development - Level 1
Android Development for Beginners with Sample Project - Day 1
Android development session
Android
Android Basic
More on Application Structure
Intro to Android Programming
Unit 2 in environment science and technology
Getting started with android studio

Recently uploaded (20)

PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Cloud computing and distributed systems.
PPTX
sap open course for s4hana steps from ECC to s4
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Big Data Technologies - Introduction.pptx
PDF
Electronic commerce courselecture one. Pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
NewMind AI Weekly Chronicles - August'25 Week I
MIND Revenue Release Quarter 2 2025 Press Release
Network Security Unit 5.pdf for BCA BBA.
Encapsulation_ Review paper, used for researhc scholars
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Spectroscopy.pptx food analysis technology
Cloud computing and distributed systems.
sap open course for s4hana steps from ECC to s4
“AI and Expert System Decision Support & Business Intelligence Systems”
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Programs and apps: productivity, graphics, security and other tools
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Big Data Technologies - Introduction.pptx
Electronic commerce courselecture one. Pdf
20250228 LYD VKU AI Blended-Learning.pptx
Per capita expenditure prediction using model stacking based on satellite ima...

Synapseindia android apps introduction hello world

  • 2. Tutorial  http://developer.android.com/resources/t utorials/hello-world.html  http://mobiforge.com/developing/story/ge tting-started-with-android-development? dm_switcher=true 2
  • 3. Create a New Android Project  From Eclipse, select File > New > Android Project.  Fill in the project details with the following values:  Project name: HelloAndroid  Application name: Hello, Android  Package name: com.example.helloandroid (or your own private namespace)  Create Activity: HelloAndroid Click Finish 3
  • 4. 4 Create a New Android Project
  • 5. Create a New Android Project  Project name - the name of the project  Package name - the name of the package. This name will be used as the package name in your Java files. Package name must be fully qualified. The convention is to use your company's domain name in reverse order  Activity name - the name of the activity in your Android application. In Android, think of an activity as a screen containing some actions, hence the name "activity"  Application name - the user-friendly name of the application that will be displayed in the Applications tab of the Android UI 5
  • 6. 6 Package Content All source code here Java code for our activity Generated Java code Helps link resources to Java code Layout of the activity Strings used in the program All non-code resources Android Manifest Images
  • 7. the various fields when create a new Android project  First, the src folder contains your Java source files. The HelloAndroid.java file is the source file for the HelloAndroid activity you specified when you created the project earlier.  The R.java file is a special file generated by the ADT to keep track of all the names of views, constants, etc, used in your Android project. You should not modify the content of this file as its content is generated automatically by the ADT.  The Android Library contains a file named android.jar. This file contains all the classes that you would use to program an Android application.  The res folder contains all the resources used by your Android application. For example, the drawable folder contains a png image file that is used as the icon for your application. The layout folder contains an XML file used to represent the user interface of your Android application. The values folder contains an XML file used to store a list of string constants.  The AndroidManifest.xml file is an application configuration file that contains detailed information about your application, such as the number of activities you have in your application, the types of permissions your application needs, the version information of your application, and so on. 7
  • 8. 8 Run the Application  The Eclipse plugin makes it easy to run your applications:  Select Run > Run.  Select "Android Application".
  • 9. 9 /res/layout/main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> </LinearLayout>
  • 10. 10 XML attributes  xmlns:android This is an XML namespace declaration that tells the Android tools that you are going to refer to common attributes defined in the Android namespace. The outermost tag in every Android layout file must have this attribute.  android:id This attribute assigns a unique identifier to the TextView element. You can use the assigned ID to reference this View from your source code or from other XML resource declarations.  android:layout_width This attribute defines how much of the available width on the screen this View should consume. In this case, it's the only View so you want it to take up the entire screen, which is what a value of "fill_parent" means.
  • 11. 11 XML attributes  android:layout_height This is just like android:layout_width, except that it refers to available screen height.  android:text This sets the text that the TextView should display. In this example, you use a string resource instead of a hard-coded string value. The hello string is defined in the res/values/strings.xml file. This is the recommended practice for inserting strings to your application, because it makes the localization of your application to other languages graceful, without need to hard-code changes to the layout file.
  • 12. /res/values/strings.xml  In Android, the UI of each activity is represented using various objects known as Views. You can create a view using code, or more simply through the use of an XML file.  In this case, the UI Is represented using an XML file.  The <TextView> element represents a text label on the screen while the <LinearLayout> element specifies how views should be arranged.  Notice that the <TextView> element has an attribute named 12 android:text with its value set to "@string/hello".  The @string/hello refers to the string named hello defined in the strings.xml file in the res/values folder. <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, HelloAndroid!</string> <string name="app_name">HelloAndroid</string> </resources>
  • 13. 13 Modify strings.xml <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello, Android! I am a string resource!</string> <string name="app_name">Hello, Android</string> </resources>
  • 15. 15 Modify the main.xml  Let's now modify the main.xml file. Add the following <Button> element: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:id="@+id/btnClickMe" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Click Me!" /> </LinearLayout>
  • 17. 17 Construct UI package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloAndroid extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView tv = new TextView(this); tv.setText("Hello, Android"); setContentView(tv); } }
  • 19. 19 R class  In Eclipse, open the file named R.java (in the gen/ [Generated Java Files] folder).  The R.java file is a special file generated by the ADT to keep track of all the names of views, constants, etc, used in your Android project. You should not modify the content of this file as its content is generated automatically by the ADT package com.example.helloandroid; public final class R { public static final class attr { } public static final class drawable { public static final int icon=0x7f020000; } public static final class id { public static final int textview=0x7f050000; } public static final class layout { public static final int main=0x7f030000; } public static final class string { public static final int app_name=0x7f040001; public static final int hello=0x7f040000; } }
  • 20. AndroidManifest.xml  The AndroidManifest.xml file is an application configuration file that contains detailed information about your application, such as the number of activities you have in your application, the types of permissions your application needs, the version information of your application, and so on. 20 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.helloandroid" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".HelloAndroid" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>