SlideShare ist ein Scribd-Unternehmen logo
1 von 37
Android Development
Made Easy   W I t h S a m
p l e   P r o j e c t
               by Joemarie Comeros Amparo
Outline:
   Overview on Android
   Installing ADT on Eclipse
   Explore Project Components
   Sample Project
Android is an open mobile phone platform that was
   developed by Google and later by Open Handset
   Alliance. Google defines Android as a "software
   stack" for mobile phones.

Software stack is made up of operating system(the
   platform on which everything runs), the middleware
   (the programming that allows applications to talk to
   a network and to one another) and the applications
   (the actual programs that phone will run)
July 2005 - Google Inc. bought from Danger Inc

Open Handset Alliance was formed headed by Google
  which is composed of companies like Intel, T-
  Mobile, Spring Nextel and more.

In 2008, Android became available as an open source
    and ASOP(Android Open Source Project) is
    responsible for maintaining and development of
    android.

February 2009, the first android version was released,
   Android 1.1. for Mobile G1.
   Android   1.1
   Android   1.5 Cupcake
   Android   1.6 Donut
   Android   2.0/2.1 Eclair
   Android   2.2.x Froyo
   Android   2.3.x Gingerbread
   Android   3. x Honeycomb
   Android   4.0.x Ice Cream Sandwich
   Android   4.1 Jelly Bean
Note: When developing an application, consider the market share of the android version. The
higher the market share, the higher number your target market is.
Note: Based on my development experience, ADT can run on at least Dual Core with at
least 2GB RAM.
Please refer to:
       www.developershaven.net
Activity
• Present a visual user interface for one focused endeavor the user can undertake
• Example: a list of menu items users can choose from

    Services
• Run in the background for an indefinite period of time
• Example: calculate and provide the result to activities that need it

   Broadcast Receivers
• Receive and react to broadcast announcements
• Example: announcements that the time zone has changed

 Content Providers
• Store and retrieve data and make it accessible to all applications
• Example: Android ships with a number of content providers for common

     Intents
• Hold the content of a message
• Example: convey a request for an activity to present an image to the user or let
  the user edit some text
public class CCSActivity extends Activity {
   /** Called when the activity is first created.
*/
   @Override
   public void onCreate(Bundle
savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);

    }
}
   Run in the background
     Can continue even if Activity that started it dies
     Should be used if something needs to be done while the
      user is not interacting with application
           Otherwise, a thread is probably more applicable
      Should create a new thread in the service to do work in,
       since the service runs in the main thread
   Can be bound to an application
     In which case will terminate when all applications bound to
       it unbind
     Allows multiple applications to communicate with it via a
       common interface
   Needs to be declared in manifest file
   Like Activities, has a structured life cycle
SRC
• The project source code

GEN
• Auto generated code
• Example: R.java

Included libraries


Resources
• Drawables
• Layout
• Values like strings
Manifest File
• A must have xml file. Contains essential information about the
  system to the android system
   Auto-generated: you shouldn’t edit it
   Contains IDs of the project resources
   Enforces good software engineering
   Use findViewById and Resources object to get
    access to the resources
       Ex. Button b = (Button)findViewById(R.id.button1)
       Ex. getResources().getString(R.string.hello));
   Eclipse has a great UI creator
       Generates the XML for you
   Composed of View objects
   Can be specified for portrait and landscape
    mode
       Use same file name, so can make completely
        different UIs for the orientations without
        modifying any code
   Click ‘Create’ to make layout modifications
   When in portrait mode can select ‘Portrait’ to
    make a res sub folder for portrait layouts
       Likewise for Landscape layouts while in landscape mode
       Will create folders titled ‘layout-port’ and ‘layout-land’
   Note: these ‘port’ and ‘land’ folders are examples
    of ‘alternate layouts’, see here for more info
       http://developer.android.com/guide/topics/resources/providing-
        resources.html

   Avoid errors by making sure components have the
    same id in both orientations, and that you’ve
    tested each orientation thoroughly
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/ap
k/res/android"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:orientation="vertical" >

  <TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:text="@string/hello"
    android:id="@+id/tv_hello"/>
  <TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text“
android:textAppearance="?android:attr/textApp   res/values/string.xml
earanceLarge"/>


</LinearLayout>
1. Lunching a new activity without expecting without expecting a result




2. Lunching a new activity and expecting a result when it finished.




CalledActivity.class
   On Eclipse IDE. Go To File >
    New > Project > Android
    Project
   See image at the side for the
    prompt that appear. Click
    next button.
   Select android version.
    Tip: select the latest OS
    version available. You can
    add minimum and target SDK
    on your manifest file to
    support earlier android
    versions.
   Provide package name of
    your project. Valid package
    name consist of two names
    separated by a period.
   Provide package name of
    your project. Valid package
    name consist of two names
    separated by a period.
   Optional: Change minimum
    SDK for the lowest android
    version your application will
    support.
   Hit on finish
   Under res/layout on your    In main.xml:



    project explorer. Open      <?xml version="1.0" encoding="utf-8"?>
                                <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                                  android:layout_width="fill_parent"
    main.xml. Create a layout     android:layout_height="fill_parent"
                                  android:orientation="vertical" >

    like this:                    <TextView
                                    android:layout_width="fill_parent"
                                    android:layout_height="wrap_content"
                                    android:text="@string/hello" />
                                  <LinearLayout
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content" >
                                     <Button
                                       android:id="@+id/button1"
                                       android:layout_width="wrap_content"
                                       android:layout_height="wrap_content"
                                       android:text="@string/button1" />
                                     <Button
                                       android:id="@+id/button2"
                                       android:layout_width="wrap_content"
                                       android:layout_height="wrap_content"
                                       android:text="Button 2" />
                                     <Button
                                       android:id="@+id/button3"
                                       android:layout_width="wrap_content"
                                       android:layout_height="wrap_content"
                                       android:text="Button 3" />
                                  </LinearLayout>
                                  <EditText
                                    android:id="@+id/editText1"
                                    android:layout_width="match_parent"
                                    android:layout_height="wrap_content"
                                    android:ems="10" >
                                    <requestFocus />
                                  </EditText>
                                </LinearLayout>
    Under res/values on your
     project explorer. Open
     strings.xml.


<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="hello">Hello World, SampleProjectActivity!</string>
    <string name="app_name">SampleProject</string>
    <string name="button1">Button 1 Clicked.</string>

</resources>




NOTE: string with name button1 is being referenced by Button 1 android:text property.
See main.xml in your layout.
    Under SRC on your project       public class SampleProjectActivity extends Activity implements OnClickListener{

     explorer. Open
                                       /** Called when the activity is first created. */
                                       @Override
                                       public void onCreate(Bundle savedInstanceState) {

     SampleProjectActivity.java.
                                          super.onCreate(savedInstanceState);
                                          setContentView(R.layout.main);
                                          Toast.makeText(this, "Hello.", Toast.LENGTH_LONG).show();
                                          //referencing components in our layout as set in setContentView, - main.xml
     Change code to this:                 //findViewById is used hence we components in our layout will be called
                                          //through their ids as set in android:id properties. See main.xml in your layout.
                                          Button btn1 = (Button)findViewById(R.id.button1);
                                          //one way in handling click event
    See comments for better              btn1.setOnClickListener(new View.OnClickListener() {
                                              @Override
                                              public void onClick(View v) {

     understand.                     application
                                                //Toast is a prompt that will notify user of what has happened in the
                                                //but not requiring user an action.
                                                Toast.makeText(getApplication(), "Button 1 Clicked",
                                     Toast.LENGTH_LONG).show();
                                              }
                                          });

import android.app.Activity;                 Button btn2 = (Button)findViewById(R.id.button2);
import android.content.Intent;               Button btn3 = (Button)findViewById(R.id.button3);
                                             //Other way of handling event inside an activity
import android.os.Bundle;                    btn2.setOnClickListener(this);
                                             btn3.setOnClickListener(this);
import android.view.View;                }
                                         @Override
import                                   public void onClick(View v) {
                                           // TODO Auto-generated method stub
android.view.View.OnClickListener;           switch(v.getId())
                                             {
import android.widget.Button;                case R.id.button2:
                                               EditText editText = (EditText)findViewById(R.id.editText1);
import android.widget.EditText;                editText.setText("Button 2 Clicked!");
                                               break;
                                             case R.id.button3:
import android.widget.Toast;                   // Intent with out waiting for result.
                                               // This is creating a new view and passing the new controll to the next view.
                                               Intent intent = new Intent(this, NextActivity.class);
                                               startActivity(intent);
                                               break;

                                             }
                                         }
                                     }
   Create NextActivity.java       import android.app.Activity;
                                   import android.os.Bundle;
   Right click SRC folder > New   import android.widget.Button;
                                   import android.widget.TextView;
    > Class.                       public class NextActivity extends Activity{

   Change code to this:               @Override
                                       public void onCreate(Bundle savedInstanceState)
                                   {
                                         super.onCreate(savedInstanceState);
                                         // you can have a new layout. but for this example
                                         // we will be reusing the main.xml as our layout.
                                         // we will just manipulate the text to inform user that
                                         //a new activity has been created.
                                         setContentView(R.layout.main);
                                         // setTitle - change the title of the next view
                                         setTitle("Next Activity");
                                        //setting page title
                                        TextView pageTitle =
                                   (TextView)findViewById(R.id.pagetitle);
                                        pageTitle.setText("Hello, You are now in the Next
                                   Activity Class.");
                                        Button btn1 = (Button)findViewById(R.id.button1);
                                        btn1.setText("Option 1");
                                        Button btn2 = (Button)findViewById(R.id.button2);
                                        btn2.setText("Option 2");
                                        Button btn3 = (Button)findViewById(R.id.button3);
                                        btn3.setText("Option 3");
                                     }
                                   }
   Open Manifest.xml in your        <?xml version="1.0" encoding="utf-8"?>
    project explorer.                <manifest
                                     xmlns:android="http://schemas.android.com/apk/re
                                     s/android"
   Register NextActivity class to      package="com.sample"
                                        android:versionCode="1"
    your project.                       android:versionName="1.0" >

   Your new manifest file must      <uses-sdk android:minSdkVersion="8"
                                     android:targetSdkVersion="15"/>
    look like the code at the          <application
                                         android:icon="@drawable/ic_launcher"
    side.                                android:label="@string/app_name" >
                                         <activity
   Save all the changes                    android:name=".SampleBradActivity"
                                            android:label="@string/app_name" >
                                            <intent-filter>
                                               <action
                                     android:name="android.intent.action.MAIN" />
                                                <category
                                     android:name="android.intent.category.LAUNCHE
                                     R" />
                                             </intent-filter>
                                           </activity>
                                           <activity
                                             android:name=".NextActivity"
                                             android:label="@string/app_name" />
                                       </application>
                                     </manifest>
   Right click your project name in your project explorer > RUN AS
    > ANDROID APPLICATION.
   Emulator will boot up. Wait until home screen is shown.
   Your application will be displayed on the screen.
   You can now enjoy the application.




             Congratulations!!!
   Installation: http://developershaven.net
   Google API: http://mfarhan133.wordpress.com/2010/10/01/generate-google-maps-api-key-for-android/
   Android Developer’s Website : http://developer.android.com/index.html
   Numerous Forums & other developer sites, including:
      http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html
      http://efreedom.com/Question/1-6070968/Google-Maps-Api-Directions
      http://stackoverflow.com
      http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html
Joemarie Comeros Amparo
               about.me/joemarieamparo
      Skype/Ymail/Gmail : joemarieamparo
     Facebook: joemarieamparo@yahoo.com

Weitere ähnliche Inhalte

Was ist angesagt?

Android Development Slides
Android Development SlidesAndroid Development Slides
Android Development SlidesVictor Miclovich
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basicsAnton Narusberg
 
android-tutorial-for-beginner
android-tutorial-for-beginnerandroid-tutorial-for-beginner
android-tutorial-for-beginnerAjailal Parackal
 
Android studio 2.0: default project structure
Android studio 2.0: default project structureAndroid studio 2.0: default project structure
Android studio 2.0: default project structureVyara Georgieva
 
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]Sittiphol Phanvilai
 
Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012Opersys inc.
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_startedAhsanul Karim
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A NutshellTed Chien
 
Android Development Training
Android Development TrainingAndroid Development Training
Android Development Trainingchandutata
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a NutshellAleix Solé
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Javaamaankhan
 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming BasicsEueung Mulyana
 
Android Studio Overview
Android Studio OverviewAndroid Studio Overview
Android Studio OverviewSalim Hosen
 
Introduction_to_android_and_android_studio
Introduction_to_android_and_android_studioIntroduction_to_android_and_android_studio
Introduction_to_android_and_android_studioAbdul Basit
 
Android application development
Android application developmentAndroid application development
Android application developmentMadhuprakashR1
 

Was ist angesagt? (20)

Google Android
Google AndroidGoogle Android
Google Android
 
Android Development Slides
Android Development SlidesAndroid Development Slides
Android Development Slides
 
Android Applications Development
Android Applications DevelopmentAndroid Applications Development
Android Applications Development
 
Android app development basics
Android app development basicsAndroid app development basics
Android app development basics
 
android-tutorial-for-beginner
android-tutorial-for-beginnerandroid-tutorial-for-beginner
android-tutorial-for-beginner
 
Android studio 2.0: default project structure
Android studio 2.0: default project structureAndroid studio 2.0: default project structure
Android studio 2.0: default project structure
 
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]What’s new in aNdroid [Google I/O Extended Bangkok 2016]
What’s new in aNdroid [Google I/O Extended Bangkok 2016]
 
Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012Android App Development Intro at ESC SV 2012
Android App Development Intro at ESC SV 2012
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_started
 
Android In A Nutshell
Android In A NutshellAndroid In A Nutshell
Android In A Nutshell
 
Android Development Training
Android Development TrainingAndroid Development Training
Android Development Training
 
Android Development in a Nutshell
Android Development in a NutshellAndroid Development in a Nutshell
Android Development in a Nutshell
 
Android Application Development Using Java
Android Application Development Using JavaAndroid Application Development Using Java
Android Application Development Using Java
 
Android Programming Basics
Android Programming BasicsAndroid Programming Basics
Android Programming Basics
 
Android session 2
Android session 2Android session 2
Android session 2
 
Android Studio Overview
Android Studio OverviewAndroid Studio Overview
Android Studio Overview
 
Introduction_to_android_and_android_studio
Introduction_to_android_and_android_studioIntroduction_to_android_and_android_studio
Introduction_to_android_and_android_studio
 
Android session 1
Android session 1Android session 1
Android session 1
 
Android application development
Android application developmentAndroid application development
Android application development
 
Android session 3
Android session 3Android session 3
Android session 3
 

Ähnlich wie Android Development Made Easy With Sample Project

Android Workshop
Android WorkshopAndroid Workshop
Android WorkshopJunda Ong
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgetsPrajyot Mainkar
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldTarunsingh198
 
android level 3
android level 3android level 3
android level 3DevMix
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_programEyad Almasri
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in androidMahmudul Hasan
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android AppsGil Irizarry
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidDenis Minja
 
01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgetsSiva Kumar reddy Vasipally
 
06. Android Basic Widget and Container
06. Android Basic Widget and Container06. Android Basic Widget and Container
06. Android Basic Widget and ContainerOum Saokosal
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android ProgrammingRaveendra R
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2Vivek Bhusal
 

Ähnlich wie Android Development Made Easy With Sample Project (20)

Android Workshop
Android WorkshopAndroid Workshop
Android Workshop
 
Android Tutorials : Basic widgets
Android Tutorials : Basic widgetsAndroid Tutorials : Basic widgets
Android Tutorials : Basic widgets
 
Synapseindia android apps introduction hello world
Synapseindia android apps introduction hello worldSynapseindia android apps introduction hello world
Synapseindia android apps introduction hello world
 
android level 3
android level 3android level 3
android level 3
 
Lec005 android start_program
Lec005 android start_programLec005 android start_program
Lec005 android start_program
 
Android
AndroidAndroid
Android
 
Android
AndroidAndroid
Android
 
Ap quiz app
Ap quiz appAp quiz app
Ap quiz app
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
Android Application Fundamentals.
Android Application Fundamentals.Android Application Fundamentals.
Android Application Fundamentals.
 
Beginning Native Android Apps
Beginning Native Android AppsBeginning Native Android Apps
Beginning Native Android Apps
 
Android Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_androidAndroid Bootcamp Tanzania:understanding ui in_android
Android Bootcamp Tanzania:understanding ui in_android
 
01 09 - graphical user interface - basic widgets
01  09 - graphical user interface - basic widgets01  09 - graphical user interface - basic widgets
01 09 - graphical user interface - basic widgets
 
Mini curso Android
Mini curso AndroidMini curso Android
Mini curso Android
 
06. Android Basic Widget and Container
06. Android Basic Widget and Container06. Android Basic Widget and Container
06. Android Basic Widget and Container
 
Introduction to Android Programming
Introduction to Android ProgrammingIntroduction to Android Programming
Introduction to Android Programming
 
Android gui framework
Android gui frameworkAndroid gui framework
Android gui framework
 
Android Intro
Android IntroAndroid Intro
Android Intro
 
Android TCJUG
Android TCJUGAndroid TCJUG
Android TCJUG
 
Training Session 2 - Day 2
Training Session 2 - Day 2Training Session 2 - Day 2
Training Session 2 - Day 2
 

Kürzlich hochgeladen

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfErwinPantujan2
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 

Kürzlich hochgeladen (20)

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdfVirtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
Virtual-Orientation-on-the-Administration-of-NATG12-NATG6-and-ELLNA.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 

Android Development Made Easy With Sample Project

  • 1. Android Development Made Easy W I t h S a m p l e P r o j e c t by Joemarie Comeros Amparo
  • 2. Outline:  Overview on Android  Installing ADT on Eclipse  Explore Project Components  Sample Project
  • 3. Android is an open mobile phone platform that was developed by Google and later by Open Handset Alliance. Google defines Android as a "software stack" for mobile phones. Software stack is made up of operating system(the platform on which everything runs), the middleware (the programming that allows applications to talk to a network and to one another) and the applications (the actual programs that phone will run)
  • 4. July 2005 - Google Inc. bought from Danger Inc Open Handset Alliance was formed headed by Google which is composed of companies like Intel, T- Mobile, Spring Nextel and more. In 2008, Android became available as an open source and ASOP(Android Open Source Project) is responsible for maintaining and development of android. February 2009, the first android version was released, Android 1.1. for Mobile G1.
  • 5. Android 1.1  Android 1.5 Cupcake  Android 1.6 Donut  Android 2.0/2.1 Eclair  Android 2.2.x Froyo  Android 2.3.x Gingerbread  Android 3. x Honeycomb  Android 4.0.x Ice Cream Sandwich  Android 4.1 Jelly Bean
  • 6. Note: When developing an application, consider the market share of the android version. The higher the market share, the higher number your target market is.
  • 7. Note: Based on my development experience, ADT can run on at least Dual Core with at least 2GB RAM.
  • 8. Please refer to: www.developershaven.net
  • 9. Activity • Present a visual user interface for one focused endeavor the user can undertake • Example: a list of menu items users can choose from Services • Run in the background for an indefinite period of time • Example: calculate and provide the result to activities that need it Broadcast Receivers • Receive and react to broadcast announcements • Example: announcements that the time zone has changed Content Providers • Store and retrieve data and make it accessible to all applications • Example: Android ships with a number of content providers for common Intents • Hold the content of a message • Example: convey a request for an activity to present an image to the user or let the user edit some text
  • 10.
  • 11. public class CCSActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } }
  • 12. Run in the background  Can continue even if Activity that started it dies  Should be used if something needs to be done while the user is not interacting with application  Otherwise, a thread is probably more applicable  Should create a new thread in the service to do work in, since the service runs in the main thread  Can be bound to an application  In which case will terminate when all applications bound to it unbind  Allows multiple applications to communicate with it via a common interface  Needs to be declared in manifest file  Like Activities, has a structured life cycle
  • 13.
  • 14. SRC • The project source code GEN • Auto generated code • Example: R.java Included libraries Resources • Drawables • Layout • Values like strings Manifest File • A must have xml file. Contains essential information about the system to the android system
  • 15.
  • 16. Auto-generated: you shouldn’t edit it  Contains IDs of the project resources  Enforces good software engineering  Use findViewById and Resources object to get access to the resources  Ex. Button b = (Button)findViewById(R.id.button1)  Ex. getResources().getString(R.string.hello));
  • 17.
  • 18.
  • 19. Eclipse has a great UI creator  Generates the XML for you  Composed of View objects  Can be specified for portrait and landscape mode  Use same file name, so can make completely different UIs for the orientations without modifying any code
  • 20.
  • 21. Click ‘Create’ to make layout modifications  When in portrait mode can select ‘Portrait’ to make a res sub folder for portrait layouts  Likewise for Landscape layouts while in landscape mode  Will create folders titled ‘layout-port’ and ‘layout-land’  Note: these ‘port’ and ‘land’ folders are examples of ‘alternate layouts’, see here for more info  http://developer.android.com/guide/topics/resources/providing- resources.html  Avoid errors by making sure components have the same id in both orientations, and that you’ve tested each orientation thoroughly
  • 22.
  • 23. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/ap k/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" android:id="@+id/tv_hello"/> <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Large Text“ android:textAppearance="?android:attr/textApp res/values/string.xml earanceLarge"/> </LinearLayout>
  • 24.
  • 25. 1. Lunching a new activity without expecting without expecting a result 2. Lunching a new activity and expecting a result when it finished. CalledActivity.class
  • 26. On Eclipse IDE. Go To File > New > Project > Android Project  See image at the side for the prompt that appear. Click next button.
  • 27. Select android version. Tip: select the latest OS version available. You can add minimum and target SDK on your manifest file to support earlier android versions.
  • 28. Provide package name of your project. Valid package name consist of two names separated by a period.
  • 29. Provide package name of your project. Valid package name consist of two names separated by a period.  Optional: Change minimum SDK for the lowest android version your application will support.  Hit on finish
  • 30. Under res/layout on your In main.xml: project explorer. Open <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" main.xml. Create a layout android:layout_height="fill_parent" android:orientation="vertical" > like this: <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/button1" /> <Button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button 2" /> <Button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button 3" /> </LinearLayout> <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > <requestFocus /> </EditText> </LinearLayout>
  • 31. Under res/values on your project explorer. Open strings.xml. <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, SampleProjectActivity!</string> <string name="app_name">SampleProject</string> <string name="button1">Button 1 Clicked.</string> </resources> NOTE: string with name button1 is being referenced by Button 1 android:text property. See main.xml in your layout.
  • 32. Under SRC on your project public class SampleProjectActivity extends Activity implements OnClickListener{ explorer. Open /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { SampleProjectActivity.java. super.onCreate(savedInstanceState); setContentView(R.layout.main); Toast.makeText(this, "Hello.", Toast.LENGTH_LONG).show(); //referencing components in our layout as set in setContentView, - main.xml Change code to this: //findViewById is used hence we components in our layout will be called //through their ids as set in android:id properties. See main.xml in your layout. Button btn1 = (Button)findViewById(R.id.button1); //one way in handling click event  See comments for better btn1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { understand. application //Toast is a prompt that will notify user of what has happened in the //but not requiring user an action. Toast.makeText(getApplication(), "Button 1 Clicked", Toast.LENGTH_LONG).show(); } }); import android.app.Activity; Button btn2 = (Button)findViewById(R.id.button2); import android.content.Intent; Button btn3 = (Button)findViewById(R.id.button3); //Other way of handling event inside an activity import android.os.Bundle; btn2.setOnClickListener(this); btn3.setOnClickListener(this); import android.view.View; } @Override import public void onClick(View v) { // TODO Auto-generated method stub android.view.View.OnClickListener; switch(v.getId()) { import android.widget.Button; case R.id.button2: EditText editText = (EditText)findViewById(R.id.editText1); import android.widget.EditText; editText.setText("Button 2 Clicked!"); break; case R.id.button3: import android.widget.Toast; // Intent with out waiting for result. // This is creating a new view and passing the new controll to the next view. Intent intent = new Intent(this, NextActivity.class); startActivity(intent); break; } } }
  • 33. Create NextActivity.java import android.app.Activity; import android.os.Bundle;  Right click SRC folder > New import android.widget.Button; import android.widget.TextView; > Class. public class NextActivity extends Activity{  Change code to this: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // you can have a new layout. but for this example // we will be reusing the main.xml as our layout. // we will just manipulate the text to inform user that //a new activity has been created. setContentView(R.layout.main); // setTitle - change the title of the next view setTitle("Next Activity"); //setting page title TextView pageTitle = (TextView)findViewById(R.id.pagetitle); pageTitle.setText("Hello, You are now in the Next Activity Class."); Button btn1 = (Button)findViewById(R.id.button1); btn1.setText("Option 1"); Button btn2 = (Button)findViewById(R.id.button2); btn2.setText("Option 2"); Button btn3 = (Button)findViewById(R.id.button3); btn3.setText("Option 3"); } }
  • 34. Open Manifest.xml in your <?xml version="1.0" encoding="utf-8"?> project explorer. <manifest xmlns:android="http://schemas.android.com/apk/re s/android"  Register NextActivity class to package="com.sample" android:versionCode="1" your project. android:versionName="1.0" >  Your new manifest file must <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15"/> look like the code at the <application android:icon="@drawable/ic_launcher" side. android:label="@string/app_name" > <activity  Save all the changes android:name=".SampleBradActivity" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHE R" /> </intent-filter> </activity> <activity android:name=".NextActivity" android:label="@string/app_name" /> </application> </manifest>
  • 35. Right click your project name in your project explorer > RUN AS > ANDROID APPLICATION.  Emulator will boot up. Wait until home screen is shown.  Your application will be displayed on the screen.  You can now enjoy the application. Congratulations!!!
  • 36. Installation: http://developershaven.net  Google API: http://mfarhan133.wordpress.com/2010/10/01/generate-google-maps-api-key-for-android/  Android Developer’s Website : http://developer.android.com/index.html  Numerous Forums & other developer sites, including:  http://www.javacodegeeks.com/2011/02/android-google-maps-tutorial.html  http://efreedom.com/Question/1-6070968/Google-Maps-Api-Directions  http://stackoverflow.com  http://www.anddev.org/google_driving_directions_-_mapview_overlayed-t826.html
  • 37. Joemarie Comeros Amparo about.me/joemarieamparo Skype/Ymail/Gmail : joemarieamparo Facebook: joemarieamparo@yahoo.com