SlideShare uma empresa Scribd logo
1 de 17
Baixar para ler offline
Building
  “HelloWorld”
Android Application
  Step by Step.



                      1
Topics
• Building blocks of Android Application
  > Activities
  > Layout resource files
  > AndroidManifest.xml
  > Resource files - strings.xml
  > R.java
Building Blocks of
Android Application
Building Blocks of Android Application
• Activity classes
• Layout resource files
• Resource files
  > strings.xml
• AndroidManifest.xml
• R.java (automatically created from resource
  files)
• Android library (automatically configured)
Building Blocks of Android Application
Activity Class
• Each Activity class typically represents a screen
  > Like a JSP page in a Web application
• The onCreate() method of Activity class gets
  called by the Android system when your
  Activity starts
  > You create your UI inside the onCreate() method
• Every Activity has to be described in the
  AndroidManifest.xml file
• An Activity is typically chosen as a starting one
  of your application - like a class that has a
  main() method in Java
  > Special configuration in AndroidManifest.xml
Activity Class Example
package com.javapassion;

import android.app.Activity;
import android.os.Bundle;

public class HelloWorldActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //Create UI using Layout resource file
        setContentView(R.layout.main);
    }
}
Layout Resource Files
• Every screen has a corresponding layout
  resource file
  > Unless you create UI programmatically
• Each activity class specifies which layout
  resource file to use for each screen it
  represents
  > Using setContentView(R.layout.main);
• Are located under /res/layout directory
  > /res/layout/main.xml layout resource file is
    referred to as R.layout.main
Layout Resource File Example
Resource Files - strings.xml
• Let you define the text strings of your
  applications in a well-known file
  > Rather than in Java code
  > Rather than in Layout resource files
• The strings are then referred to through the
  names assigned to them
  > The mapping is done through R.java
  > @string/hello (in the layout resource file)
  > R.string.hello (in the Java code)
• Located under /res/values directory
strings.xml Resource File
AndroidManifest.xml file
• Every application must have a manifest file
  called AndroidManifest.xml file (with precisely
  that name) in its root directory.
• The manifest presents essential information
  about the application to the Android system,
  information the system must have before it can
  run any of the application's code.
Info. in AndroidManifest.xml file
• Java package for the application.
  > The package name serves as a unique identifier for
    the application.
• Activities
  > One activity is designated as a starting Activity

 <activity android:name=".HelloWorldActivity"
 android:label="@string/app_name">
    <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category
         android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
 </activity>
AndroidManifest.xml
R.java
• Automatically created by Android system for all
  resources defined
R.java
Thank you

Mais conteúdo relacionado

Mais procurados

Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniterAhmad Arif
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android ApplicationMark Lester Navarro
 
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...DicodingEvent
 
Getting Started with Rails
Getting Started with RailsGetting Started with Rails
Getting Started with RailsBasayel Said
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database TutorialPerfect APK
 

Mais procurados (7)

Database in Android
Database in AndroidDatabase in Android
Database in Android
 
Having fun with code igniter
Having fun with code igniterHaving fun with code igniter
Having fun with code igniter
 
Databases in Android Application
Databases in Android ApplicationDatabases in Android Application
Databases in Android Application
 
Android Database
Android DatabaseAndroid Database
Android Database
 
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
Dicoding Developer Coaching #26: Android | Menyimpan Database dengan Lebih Si...
 
Getting Started with Rails
Getting Started with RailsGetting Started with Rails
Getting Started with Rails
 
Android Database Tutorial
Android Database TutorialAndroid Database Tutorial
Android Database Tutorial
 

Destaque (8)

2310 b 05
2310 b 052310 b 05
2310 b 05
 
2310 b 06
2310 b 062310 b 06
2310 b 06
 
2310 b 03
2310 b 032310 b 03
2310 b 03
 
Android datastorage
Android datastorageAndroid datastorage
Android datastorage
 
2310 b 01
2310 b 012310 b 01
2310 b 01
 
Android search
Android searchAndroid search
Android search
 
2310 b 02
2310 b 022310 b 02
2310 b 02
 
Android security
Android securityAndroid security
Android security
 

Semelhante a Android stepbystep

Android application development
Android application developmentAndroid application development
Android application developmentslidesuren
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_programEyad Almasri
 
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureAndroid Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureNicheTech Com. Solutions Pvt. Ltd.
 
Android Development
Android DevelopmentAndroid Development
Android Developmentmclougm4
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldTarunsingh198
 
Android project architecture
Android project architectureAndroid project architecture
Android project architectureSourabh Sahu
 
Cross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipseCross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipsePeter Friese
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycleKumar
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development PracticesRoy Clarkson
 
03 android application structure
03 android application structure03 android application structure
03 android application structureSokngim Sa
 
Android introduction
Android introductionAndroid introduction
Android introductionPingLun Liao
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversUtkarsh Mankad
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptbharatt7
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart JfokusLars Vogel
 
Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & ...
Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & ...Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & ...
Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & ...Eng Teong Cheah
 
Advance Android application development workshop day 3
Advance Android application development workshop day 3Advance Android application development workshop day 3
Advance Android application development workshop day 3cresco
 
When using Android Studio- what is the purpose of the R-java file- Doe.docx
When using Android Studio- what is the purpose of the R-java file- Doe.docxWhen using Android Studio- what is the purpose of the R-java file- Doe.docx
When using Android Studio- what is the purpose of the R-java file- Doe.docxSUKHI5
 

Semelhante a Android stepbystep (20)

Android application development
Android application developmentAndroid application development
Android application development
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architectureAndroid Training Ahmedabad , Android Course Ahmedabad, Android architecture
Android Training Ahmedabad , Android Course Ahmedabad, Android architecture
 
Android Programming.pptx
Android Programming.pptxAndroid Programming.pptx
Android Programming.pptx
 
Android Development
Android DevelopmentAndroid Development
Android Development
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello world
 
Android project architecture
Android project architectureAndroid project architecture
Android project architecture
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Cross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with EclipseCross-Platform Native Mobile Development with Eclipse
Cross-Platform Native Mobile Development with Eclipse
 
Android lifecycle
Android lifecycleAndroid lifecycle
Android lifecycle
 
Native Android Development Practices
Native Android Development PracticesNative Android Development Practices
Native Android Development Practices
 
03 android application structure
03 android application structure03 android application structure
03 android application structure
 
Basic Android
Basic AndroidBasic Android
Basic Android
 
Android introduction
Android introductionAndroid introduction
Android introduction
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
MD-IV-CH-ppt.ppt
MD-IV-CH-ppt.pptMD-IV-CH-ppt.ppt
MD-IV-CH-ppt.ppt
 
Android Jumpstart Jfokus
Android Jumpstart JfokusAndroid Jumpstart Jfokus
Android Jumpstart Jfokus
 
Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & ...
Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & ...Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & ...
Learn Xamarin Absolute Beginners - Application Manifest, Android Resources & ...
 
Advance Android application development workshop day 3
Advance Android application development workshop day 3Advance Android application development workshop day 3
Advance Android application development workshop day 3
 
When using Android Studio- what is the purpose of the R-java file- Doe.docx
When using Android Studio- what is the purpose of the R-java file- Doe.docxWhen using Android Studio- what is the purpose of the R-java file- Doe.docx
When using Android Studio- what is the purpose of the R-java file- Doe.docx
 

Mais de Krazy Koder (20)

2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xd
2310 b xd2310 b xd
2310 b xd
 
2310 b xc
2310 b xc2310 b xc
2310 b xc
 
2310 b xb
2310 b xb2310 b xb
2310 b xb
 
2310 b 17
2310 b 172310 b 17
2310 b 17
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 16
2310 b 162310 b 16
2310 b 16
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 15
2310 b 152310 b 15
2310 b 15
 
2310 b 14
2310 b 142310 b 14
2310 b 14
 
2310 b 13
2310 b 132310 b 13
2310 b 13
 
2310 b 12
2310 b 122310 b 12
2310 b 12
 
2310 b 11
2310 b 112310 b 11
2310 b 11
 
2310 b 10
2310 b 102310 b 10
2310 b 10
 
2310 b 09
2310 b 092310 b 09
2310 b 09
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 08
2310 b 082310 b 08
2310 b 08
 
2310 b 07
2310 b 072310 b 07
2310 b 07
 

Android stepbystep

  • 1. Building “HelloWorld” Android Application Step by Step. 1
  • 2. Topics • Building blocks of Android Application > Activities > Layout resource files > AndroidManifest.xml > Resource files - strings.xml > R.java
  • 4. Building Blocks of Android Application • Activity classes • Layout resource files • Resource files > strings.xml • AndroidManifest.xml • R.java (automatically created from resource files) • Android library (automatically configured)
  • 5. Building Blocks of Android Application
  • 6. Activity Class • Each Activity class typically represents a screen > Like a JSP page in a Web application • The onCreate() method of Activity class gets called by the Android system when your Activity starts > You create your UI inside the onCreate() method • Every Activity has to be described in the AndroidManifest.xml file • An Activity is typically chosen as a starting one of your application - like a class that has a main() method in Java > Special configuration in AndroidManifest.xml
  • 7. Activity Class Example package com.javapassion; import android.app.Activity; import android.os.Bundle; public class HelloWorldActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Create UI using Layout resource file setContentView(R.layout.main); } }
  • 8. Layout Resource Files • Every screen has a corresponding layout resource file > Unless you create UI programmatically • Each activity class specifies which layout resource file to use for each screen it represents > Using setContentView(R.layout.main); • Are located under /res/layout directory > /res/layout/main.xml layout resource file is referred to as R.layout.main
  • 10. Resource Files - strings.xml • Let you define the text strings of your applications in a well-known file > Rather than in Java code > Rather than in Layout resource files • The strings are then referred to through the names assigned to them > The mapping is done through R.java > @string/hello (in the layout resource file) > R.string.hello (in the Java code) • Located under /res/values directory
  • 12. AndroidManifest.xml file • Every application must have a manifest file called AndroidManifest.xml file (with precisely that name) in its root directory. • The manifest presents essential information about the application to the Android system, information the system must have before it can run any of the application's code.
  • 13. Info. in AndroidManifest.xml file • Java package for the application. > The package name serves as a unique identifier for the application. • Activities > One activity is designated as a starting Activity <activity android:name=".HelloWorldActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
  • 15. R.java • Automatically created by Android system for all resources defined