SlideShare a Scribd company logo
1 of 75
Download to read offline
Editor
Nguyễn Đức Minh Khôi
nguyenducminhkhoi@gmail.com
nguyenducminhkhoi.blogspot.com




Training
Android
@HCMC University of Technology
Summer 2012
Page: 4
                           Training Android   June 2012




Introduction – What is Android?
The  Android operating system was developed by
Android, Inc.,
Was acquired by Google in July 2005.
Developing Android apps is the openness of the
platform
The operating system is open source and free.
Page: 6
                              Training Android      June 2012




Introduction (cont.)
Java:
   was   a logical choice for the Android platform
   enables you to develop apps that will run on a variety of
   devices without any platform-specific code.
   is object oriented and has access to powerful class
   libraries that help you develop apps quickly.
Page: 7
                              Training Android      June 2012




Introduction (cont.)
XML:
  enables    you to better separate the presentation of your
  application from the code that controls its behavior.
  makes it easier to visualize the structure of your UI, so
  it's easier to debug problems
  Is similar to HTML
Page: 8
                      Training Android   June 2012


Introduction (cont.)
Multitouch screen:
Page: 9
                                Training Android   June 2012


 Introduction (cont.)


Android versions:
   Android 1.6 (Donut)
   Android 2.0–2.1 (Eclair)
   Android 2.2 (Froyo)
   Android 2.3 (Gingerbread)
   Android 3.0 (Honeycomb)
   Android 4.0 (Ice  Cream Sandwich)
    Android 5.0 (Jelly Beans)
See more at:
http://developer.android.com/resources/dashboard/platform
-versions.html
Page: 10
                             Training Android     June 2012




Introduction (cont.)
Types  of android apps (go to
https://play.google.com/store) for more details
Other sites you can download apps:
Page: 11
                 Training Android   June 2012




Introduction (cont.)
Page: 12
                             Training Android     June 2012




How to set up
Software and hardware system requirement:
   To develop Android apps you need a Windows®,
   Linux or Mac OS X system.
   Java SE 5 or higher Software Development Kit
   Eclipse 3.7 (Indigo) IDE for Java Developers
   Android SDK versions 2.2, 2.3.3 and 3.x
   ADT (Android Development Tools) Plugin for Eclipse
Page: 13
                                  Training Android         June 2012


How to set up (cont.)
Install JDK (Java Development Kit) 6:
   Go to www.oracle.com/technetwork/java/javase/index-
   137561.html
Install Eclipse IDE
    Go to www.eclipse.org/downloads
    Choose Eclipse IDE for Java Developers
Install the Android SDK
    Go  to www.developer.android.com/sdk/index.html
    Click and choose your suitable platform
Install ADT plugin for Eclipse
   Go to www.developer.android.com/sdk/eclipse-adt.html
    carefully  follow the instructions for downloading
    and installing the ADT Plugin
Page: 14
                             Training Android   June 2012


How to set up (cont.)
Install Android platform:
Page: 15
                 Training Android   June 2012


How to set up (cont.)
Page: 16
                                Training Android       June 2012


How to set up (cont.)
Creating Android Virtual Device (AVD):
   The Android emulator,  included in the Android SDK,
   allows you to run Android apps in a simulated environment
   on your computer rather than on an actual Android device.
Page: 17
                 Training Android   June 2012


How to set up (cont.)
Page: 18
                             Training Android   June 2012




Source for learning
Best resource for learning and referencing:
http://developer.android.com/index.html
Page: 19
                  Training Android   June 2012




Source for learning (cont.)
Page: 20
                  Training Android   June 2012




Source for learning (cont.)
Page: 22
                Training Android   June 2012




Welcome apps (cont.)
Page: 23
              Training Android   June 2012



Eclipse IDE
Page: 24
Training Android      June 2012


 Eclipse IDE (cont.)
           Create new Project:
Page: 25
                                            Training Android   June 2012



Eclipse IDE (cont.)
Platform          Codename      API Level
Android 1.5       Cupcake       3
Android 1.6       Donut         4
Android 2.1       Eclair        7
Android 2.2       Froyo         8
Android 2.3 -     Gingerbread   9
Android 2.3.2
Android 2.3.3 -   10
Android 2.3.7
Android 3.0       Honeycomb     11
Android 3.1       12

Android 3.2       13

Android 4.0 -     Ice Cream     14
Android 4.0.2     Sandwich
Android 4.0.3 -   15
Android 4.0.4
Page: 26
                 Training Android   June 2012



Developing GUI
Page: 27
                 Training Android   June 2012


Developing GUI (cont.)
Page: 28
                 Training Android   June 2012


Developing GUI (cont.)
Page: 29
                 Training Android   June 2012



Developing GUI (cont.)
Page: 30
                 Training Android   June 2012



Developing GUI (cont.)
Page: 31
                 Training Android   June 2012


Developing GUI (cont.)
Page: 32
               Training Android           June 2012



Running the Welcome apps
                                  To run the app in
                                  an Android
                                  Virtual Device
                                  (AVD), right click
                                  the app’s root
                                  node in
                                  the Package
                                  Explorer window
                                  and select Run
                                  As > Android
                                  Application.
Page: 33
                                  Training Android   June 2012




Building Features
Each app below will expand on one Class hour
By practicing these apps you will learn some
interesting features
Each app will contain:
   Introductionsand objectives
   New Features
   Building GUI
   Adding functions
   Results
Page: 34
                                  Training Android   June 2012




Building Features
Each app below will expand on one Class hour
By practicing these apps you will learn some
interesting features
Each app will contain:
   Introductionsand objectives
   Technologies Overview
   Building GUI
   Adding functions
   Results
Page: 35
                             Training Android   June 2012




Building Features (cont.)
1.Tip Calculator App
2.Favorite Twitter Searches App
3.Flag Quiz Game App
4.Cannon Game App
5.Spot on Game App
6.Doodlz App
7.Address Book App
8.Slideshow App
9.Enhanced Slideshow App
10.Weather Viewer App
Page: 36
                             Training Android   June 2012




 Tips Calculator App
Objectives:
Building an Android App with
Java
Design a GUI using a
TableLayout
Directly edit the XML of a GUI
layout to customize properties
Use Android Activity’s subclass
interact with EditTexts, a
TextView and a SeekBar.
Page: 37
                              Training Android    June 2012


Tips Calculator App (cont.)
Introduction:
“The Tip Calculator app calculates and displays tips
for a restaurant bill. As the user enters a bill total,
the app calculates and displays the tip amount and
total bill for three common tipping percentages—
10%, 15% and 20%. The user can also specify a
custom tip percentage by moving the thumb of a
Seekbar—this updates the percentage shown to the
right of the Seekbar. The suggested tips and bill
totals are updated in response to each user
interaction.”
Page: 38
                                     Training Android        June 2012


 Tips Calculator App (cont.)
Technologies Overview:
TableLayout and TableRow introduction
See more at:
•www.developer.android.com/reference/android/widget/TableLayout.html
•www.developer.android.com/reference/android/widget/TableRow.html
Page: 39
                            Training Android   June 2012


Tips Calculator App (cont.)
Building GUI:
Create GUI with the following information
Page: 40
                            Training Android   June 2012




Tips Calculator App (cont.)
main.xml describe GUI like figure above
String.xml
Page: 41
                                  Training Android       June 2012




Tips Calculator App (cont.)
Adding Functions:
Remember     when you want to import some library, use just
type the name of the class (don’t need to complete) and press
(Ctrl + Space), it will import immediately
Class Activity of package android.app provides the basic
lifecycle methods of an app—we’ll discuss these shortly.
Class Bundle of package android.os represents an app’s state
information. An app can save its state when it’s sent to the
background by the operating system—for example, when the
user launches another app or a phone call is received.
Page: 42
                                           Training Android            June 2012



  Tips Calculator App (cont.)
Android apps doesn’t have main method
four types of components—activities, services,         content providers and
broadcast receivers
A separate activity is typically associated with each screen of an app
Throughout its life an activity can be in one of several states—active (or
running), paused or stopped.
    An   active (or running) activity is visible on the screen and “has the focus”
    A paused activity is visible on the screen but doesn’t have the focus. can be
    killed when its memory is needed by the operating system
    A stopped activity is not visible on the screen and is likely to be killed by the
    system when its memory is needed.
See more at:
www.developer.android.com/reference/android/app/Activity.html
Page: 43
                                Training Android          June 2012




Tips Calculator App (cont.)
Override method:
    onCreate:  called by the system when an Activity is
    starting—that is, when its GUI is about to be
    displayed so that the user can interact with the
    Activity.
    onSaveInstanceState: called by the system when the
    configuration of the device changes during the app’s
    execution
 Remember: Each activity lifecycle method you override
must call the superclass’s version of that method first;
otherwise, an exception will be thrown when that method is
called.
Page: 44
                               Training Android       June 2012




Tips Calculator App (cont.)
R content class:
   Class drawable—contains      constants for any drawable
   items, such as images, that you put in the various
   drawable folders in your app’s res folder
   Class id—contains constants for the GUI components
   in your XML layout files
   Class layout—contains constants that represent each
   layout file in your project (such as, main.xml)
   Class string—contains constants for each String in
   the strings.xml file
Page: 45
                 Training Android   June 2012


Tips Calculator App (cont.)
 Results:
Page: 46
                                 Training Android        June 2012


Favorite Twitter Searches App
 Objectives:
 SharedPreferences, Buttons, Nested Layouts, Intents,
 AlertDialogs, Inflating XML Layouts and the Manifest File
 Use a ScrollView to display objects that do not fit on the
 screen.
 Programmatically open a website in a web browser by
 using an Intent.
 Programmatically hide the soft keyboard.
Page: 47
                                  Training Android        June 2012


Favorite Twitter Searches App (cont.)
   Introduction:
   “The Favorite Twitter Searches    app allows users to save
   their favorite (possibly lengthy) Twitter search strings
   with easy-to-remember, user-chosen, short tag names.
   Users can then conveniently follow the tweets on their
   favorite topics. Twitter search queries can be finely tuned
   using Twitter’s search operators
   (dev.twitter.com/docs/using-search)—but more complex
   queries are lengthy, time consuming and error prone to
   type on a mobile device. The user’s favorite searches are
   saved on the device, so they’re immediately available
   each time the app launches.”
Page: 48
                   Training Android   June 2012


Favorite Twitter Searches App (cont.)
Page: 49
                                      Training Android           June 2012


Favorite Twitter Searches App (cont.)
   Technologies     Overview:
   ScrollView: is  a ViewGroup that can contain other Views (like a layout)
   and that lets users scroll through content too large to display on the
   screen.
   To read the key/value pairs from this file we’ll use SharedPreferences
   objects (package android.content). To modify the file’s contents, we’ll
   use SharedPreferences.Editor objects (package android.content). The
   keys in the file must be Strings, and the values can be Strings or
   primitive-type values
   Intents are typically used to launch activities—they indicate an action
   to be performed and the data on which that action is to be performed.
   We load the URL into a web browser by creating a new Intent for
   viewing a URL, then passing that Intent to the startActivity method,
   which our Activity inherits indirectly from class Context
Page: 50
                                      Training Android          June 2012


Favorite Twitter Searches App (cont.)
   New    Features:
   LayoutInflater programmatically creates    these GUI components
   from a predefined XML layout. The LayoutInflater inflates an XML
   layout file, thus creating the components specified in the XML.
   You can display messages and confirmations like these with an
   AlertDialog. We specify the settings for the dialog with an
   AlertDialog.Builder object, then use it to create the AlertDialog.
   The AndroidManifest.xml file is created for you when you
   create an app using the ADT Plugin in Eclipse. This file specifies
   settings such as the app’s name, the package name, the target
   and minimum SDKs, the app’s Activity name(s) and more
Page: 51
                        Training Android   June 2012


Favorite Twitter Searches App (cont.)
   Building the GUI:
Page: 52
                                     Training Android          June 2012


Favorite Twitter Searches App (cont.)
   Adding functions:
   Package android.widget contains the widgets (i.e., GUI
   components) and layouts that are used in Android GUIs. Class
   Button of package android.widget represents a simple push
   button that the user touches to get the app to perform a specific
   action. You implement interface View.OnClickListener of package
   android.view to specify the code that should execute when the
   user touches a Button
   Overridden Method OnCreate of Class Activity, called by system
   when:
       when   the app loads
       if the app’s process was killed by the operating system while the
       app was in the background, and the app is then restored
       each time the configuration changes, such as when the user
       rotates the device or opens/closes a physical keyboard.
Page: 53
                                      Training Android           June 2012


Favorite Twitter Searches App (cont.)
   Adding functions:
   Method getSharedPreferences      to get a SharedPreferences
   object that can read tag/query pairs stored previously (if any) from
   the "searches" file.
   The first argument indicates the name of the file that contains
   the data.
   The second argument specifies the accessibility of the file and
   can be set to one of the following options:
       MODE_PRIVATE— The         file is accessible only to this app. In most
       cases, you’ll use this constant as the second argument to
       getSharedPreferences.
       MODE_WORLD_READABLE— Any app on the device can read from
       the file.
       MODE_WORLD_WRITABLE— Any app on the device can write to
       the file.
Page: 54
                                  Training Android   June 2012


Favorite Twitter Searches App (cont.)
   AndroidManifest.xml
   For complete information, refer to this
                                       page:
   www.developer.android.com/guide/topics/manifest/manif
   est-intro.html
Page: 55
                   Training Android   June 2012


Favorite Twitter Searches App (cont.)
Page: 56
                             Training Android      June 2012


           Flag Quiz Game App
Objectives:
Assets, AssetManager, Tweened Animations, Handler, Menus
and Logging Error Messages.
Use an AssetManager to get a list of all assets in an app.
Use random-number generation to vary flag choices.
Use a Drawable to display a flag image in an ImageView.
Use a Handler to schedule a future action.
Use an ArrayList to hold collections of items and a
HashMap to hold name–value pairs.
Override Activity’s onCreateOptionsMenu method to create a
Menu and MenuItems that enable the user to configure the
app’s options.
Use Android’s logging mechanism to log error messages.
Page: 57
                                  Training Android      June 2012


      Flag Quiz Game App (cont.)
    Introduction:
“The Flag Quiz Game app tests the user’s ability to correctly
identify country flags. Initially, the app presents the user with a
flag image and three possible answers—one matches the flag
and the others are randomly selected, nonduplicated incorrect
answers. The app displays the user’s progress throughout the
quiz, showing the question number (out of 10) in a TextView
above the current flag image.”
Page: 58
             Training Android   June 2012


Flag Quiz Game App (cont.)
Page: 59
                                     Training Android           June 2012


   Flag Quiz Game App (cont.)
Technologies      Overview:
Using the     App’s assets Folder: the assets folder may contain files of any
type that can be organized in subfolders—we maintain the flag images for
each region in a separate subfolder. Files in the assets folders are accessed
via an AssetManager (package android.content.res), which can provide a
list of all of the file names in a specified subfolder of assets and can be
used to access each asset.
Using a Menu to Provide App Options: override Activity’s
onCreateOptionsMenu method and add the options to the Menu that the
method receives as an argument. Activity method
onOptionsItemSelected is called to respond to the selection.
Using a Handler to Execute a Runnable in the Future: . Handler method
postDelayed receives as arguments a Runnable to execute and a delay in
milliseconds.
Page: 60
                                    Training Android          June 2012


   Flag Quiz Game App (cont.)
Technologies     Overview (cont.):
Animating the Flag When     an Incorrect Choice Is Touched:
AnimationUtils static method loadAnimation to load the animation from
an XML file that specifies the animation’s options. We also specify the
number of times the animation should repeat with Animation method
setRepeatCount and perform the animation by calling View method
startAnimation (with the Animation as an argument) on the ImageView.
Logging Exception Messages with Log.e: When exceptions occur, you
can log them for debugging purposes with Android’s built-in logging
mechanism, which uses a circular buffer to store the messages for a short
time. Android provides class Log (package android.util) with several static
methods that represent messages of varying detail.
Java Data Structures: ArrayList<String>, Map<String, Boolean>,
Set<String>
Page: 61
                           Training Android   June 2012


  Flag Quiz Game App (cont.)
Building the App   GUI:
Main.xml Linear Layout
Page: 62
                             Training Android   June 2012


  Flag Quiz Game App (cont.)
colors.xml   & dimen.xml:
Page: 63
               Training Android   June 2012


  Flag Quiz Game App (cont.)
string.xml:
Page: 64
             Training Android   June 2012


Flag Quiz Game App (cont.)
Page: 65
                                      Training Android        June 2012


   Flag Quiz Game App (cont.)
Study more:
View   animations to create a shake effect that consists of three
animations in an animation set a collection of animations which make up
a larger animation. Animation sets may contain any combination of
tweened animations— alpha (transparency), scale (resize), translate
(move) and rotate.
android:fromXDelta attribute is the View’s offset when the animation
starts and the android:toXDelta attribute is the View’s offset when the
animation ends. These attributes can have
     absolute values (in pixels)
     a percentage of the animated View’s size
     a percentage of the animated View’s parent’s size
The   android:duration attribute specifies how long the animation lasts in
milliseconds.
android:startOffset attribute to specify the number of milliseconds into
the future at which an animation should begin.
Page: 66
                        Training Android   June 2012


  Flag Quiz Game App (cont.)
Building the App
AndroidManifest.xml:
Page: 67
                              Training Android       June 2012


          Cannon Game App
Objectives:
Create  a simple game app that’s easy to code and fun to play.
Create a custom SurfaceView subclass and use it to display the
game’s graphics from a separate thread of execution.
Draw graphics using Paints and a Canvas.
Override Activity’s onTouchEvent to process touch events when
the user touches the screen or drags a finger on the screen.
Use a GestureDetector to recognize more sophisticated user
touch motions, such as double taps.
Perform simple collision detection.
Add sound to your app using a SoundPool and the
AudioManager.
Override three additional Activity lifecycle methods.
Page: 68
                                Training Android     June 2012


       Cannon Game App (cont.)
   Introduction:
“The Cannon Game app challenges you to destroy a seven-
piece target before a ten-second time limit expires. The game
consists of four visual components—a cannon that you control,
a cannonball, the target and a blocker that defends the target.
You aim the cannon by touching the screen—the cannon then
aims at the touched point. The cannon fires a cannonball when
you double-tap the screen. At the end of the game, the app
displays an AlertDialog indicating whether you won or lost, and
showing the number of shots fired and the elapsed time”
Page: 69
            Training Android   June 2012


Cannon Game App (cont.)
Page: 70
            Training Android   June 2012


Cannon Game App (cont.)
Page: 71
                                     Training Android             June 2012


    Cannon Game App (cont.)
Technologies Overview
Defining  String Formatting Resources in strings.xml
Attaching a Custom View to a Layout
Using the Resource Folder raw
Activity Lifecycle Methods onPause and onDestroy:
    Method    onPause is called for the current Activity when another activity
    receives the focus, which sends the current activity to the background. We
    use onPause to suspend game play so that the game does not continue
    executing when the user cannot interact with it.
    When an Activity is shut down, its onDestroy method is called. We use this
    method to release the app’s sound resources.
Overriding Activity Method onTouchEvent
Page: 72
                                  Training Android            June 2012


   Cannon Game App (cont.)
Technologies Overview (cont.)
GestureDetector and SimpleOnGestureListener:
   A GestureDetector allows     an app to react to more sophisticated
   user interactions such as flings, double-taps, long presses and scrolls.
   Your apps can respond to such events by implementing the methods
   of the GestureDetector.
   GestureDetector.SimpleOnGestureListener is an adapter class that
   implements all the methods of these two interfaces, so you can
   extend this class and override just the method(s) you need from
   these interfaces.
Adding Sound with   SoundPool and AudioManager
Frame-by-Frame Animation with Threads, SurfaceView and
SurfaceHolder
Simple Collision Detection
Drawing Graphics Using Paint and Canvas
Page: 73
                               Training Android   June 2012


    Cannon Game App (cont.)
Building App’s GUI and resource files:
Page: 74
                               Training Android     June 2012


    Cannon Game App (cont.)
Building App’s GUI and resource files   (cont.):
Page: 75
                                    Training Android           June 2012


    Cannon Game App (cont.)
Building App’s GUI and resource files      (cont.):
The  notation 1$ in %1$.1f (line 5) indicates that the first argument after
the format String should replace the format specifier %1$d. Similarly,
%2$.1f indicates that the second argument after the format String should
replace the format specifier %2$.1f.

Adding functions (regarding to         instructors)

More Related Content

What's hot

Lecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewLecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewAhsanul Karim
 
Lecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedLecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedAhsanul Karim
 
Android Development Training
Android Development TrainingAndroid Development Training
Android Development Trainingchandutata
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from ScratchTaufan Erfiyanto
 
Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorialnazzf
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedAhsanul Karim
 
Day 2 android internals a quick overview
Day 2 android internals a quick overviewDay 2 android internals a quick overview
Day 2 android internals a quick overviewAhsanul Karim
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)Ahsanul Karim
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principlesHenk Laracker
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_startedAhsanul Karim
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorialkatayoon_bz
 

What's hot (20)

Lecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick OverviewLecture 2(b) Android Internals A Quick Overview
Lecture 2(b) Android Internals A Quick Overview
 
Lecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting StartedLecture 1 Session 1 Before Getting Started
Lecture 1 Session 1 Before Getting Started
 
AndroidManifest
AndroidManifestAndroidManifest
AndroidManifest
 
Android Development Training
Android Development TrainingAndroid Development Training
Android Development Training
 
Android session 1
Android session 1Android session 1
Android session 1
 
Android session 2
Android session 2Android session 2
Android session 2
 
Android Development: Build Android App from Scratch
Android Development: Build Android App from ScratchAndroid Development: Build Android App from Scratch
Android Development: Build Android App from Scratch
 
Android session 3
Android session 3Android session 3
Android session 3
 
Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorial
 
Android 1.8 sensor
Android 1.8 sensorAndroid 1.8 sensor
Android 1.8 sensor
 
Android Services
Android ServicesAndroid Services
Android Services
 
Android Basic- CMC
Android Basic- CMCAndroid Basic- CMC
Android Basic- CMC
 
Introduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting StartedIntroduction to Android Development: Before Getting Started
Introduction to Android Development: Before Getting Started
 
Day 2 android internals a quick overview
Day 2 android internals a quick overviewDay 2 android internals a quick overview
Day 2 android internals a quick overview
 
Ui layout (incomplete)
Ui layout (incomplete)Ui layout (incomplete)
Ui layout (incomplete)
 
Android basic principles
Android basic principlesAndroid basic principles
Android basic principles
 
Unit2
Unit2Unit2
Unit2
 
Android
AndroidAndroid
Android
 
Day1 before getting_started
Day1 before getting_startedDay1 before getting_started
Day1 before getting_started
 
Android tutorial
Android tutorialAndroid tutorial
Android tutorial
 

Viewers also liked

Android before getting started
Android before getting startedAndroid before getting started
Android before getting startedAhsanul Karim
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAhsanul Karim
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Ahsanul Karim
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesAhsanul Karim
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAhsanul Karim
 
Android GPS Tutorial
Android GPS TutorialAndroid GPS Tutorial
Android GPS TutorialAhsanul Karim
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Ahsanul Karim
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentAhsanul Karim
 
Android MapView and MapActivity
Android MapView and MapActivityAndroid MapView and MapActivity
Android MapView and MapActivityAhsanul Karim
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsAhsanul Karim
 

Viewers also liked (13)

Android before getting started
Android before getting startedAndroid before getting started
Android before getting started
 
Client-Server
Client-ServerClient-Server
Client-Server
 
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & SpinnerAndroid User Interface Tutorial: DatePicker, TimePicker & Spinner
Android User Interface Tutorial: DatePicker, TimePicker & Spinner
 
Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]Day 5: Android User Interface [View Widgets]
Day 5: Android User Interface [View Widgets]
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Day 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through ActivitiesDay 4: Android: Getting Active through Activities
Day 4: Android: Getting Active through Activities
 
Android User Interface: Basic Form Widgets
Android User Interface: Basic Form WidgetsAndroid User Interface: Basic Form Widgets
Android User Interface: Basic Form Widgets
 
Android GPS Tutorial
Android GPS TutorialAndroid GPS Tutorial
Android GPS Tutorial
 
Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)Day: 1 Introduction to Mobile Application Development (in Android)
Day: 1 Introduction to Mobile Application Development (in Android)
 
Day 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver ComponentDay 6: Android BroadcastReceiver Component
Day 6: Android BroadcastReceiver Component
 
Android MapView and MapActivity
Android MapView and MapActivityAndroid MapView and MapActivity
Android MapView and MapActivity
 
List Views
List ViewsList Views
List Views
 
Day 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViewsDay 8: Dealing with Lists and ListViews
Day 8: Dealing with Lists and ListViews
 

Similar to Training android

Android app development.pdf
Android app development.pdfAndroid app development.pdf
Android app development.pdfAbanti Aazmin
 
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...IJCNCJournal
 
report A K Maurya.pdf
report A K Maurya.pdfreport A K Maurya.pdf
report A K Maurya.pdfSonu62614
 
Latest Android App Development Tools 2019
Latest Android App Development Tools 2019Latest Android App Development Tools 2019
Latest Android App Development Tools 2019Elijahj Williams
 
[Android] Introduction to Android Programming
[Android] Introduction to Android Programming[Android] Introduction to Android Programming
[Android] Introduction to Android ProgrammingNikmesoft Ltd
 
Introduction To Android For Beginners.
Introduction To Android For Beginners.Introduction To Android For Beginners.
Introduction To Android For Beginners.Sandeep Londhe
 
How to create android applications
How to create android applicationsHow to create android applications
How to create android applicationsTOPS Technologies
 
Slite of Mid-term presentation
Slite of Mid-term presentationSlite of Mid-term presentation
Slite of Mid-term presentationAnjan Kumar kc
 
androidPramming.ppt
androidPramming.pptandroidPramming.ppt
androidPramming.pptBijayKc16
 
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.
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 
Ppt of tutorial android app
Ppt of tutorial android appPpt of tutorial android app
Ppt of tutorial android appDharmendra Saini
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidbantyder
 
Introduction to Android App Development
Introduction to Android App DevelopmentIntroduction to Android App Development
Introduction to Android App DevelopmentTodd Burgess
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development pptsaitej15
 

Similar to Training android (20)

Android app development.pdf
Android app development.pdfAndroid app development.pdf
Android app development.pdf
 
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
AN IDE FOR ANDROID MOBILE PHONES WITH EXTENDED FUNCTIONALITIES USING BEST DEV...
 
report A K Maurya.pdf
report A K Maurya.pdfreport A K Maurya.pdf
report A K Maurya.pdf
 
Latest Android App Development Tools 2019
Latest Android App Development Tools 2019Latest Android App Development Tools 2019
Latest Android App Development Tools 2019
 
[Android] Introduction to Android Programming
[Android] Introduction to Android Programming[Android] Introduction to Android Programming
[Android] Introduction to Android Programming
 
Introduction To Android For Beginners.
Introduction To Android For Beginners.Introduction To Android For Beginners.
Introduction To Android For Beginners.
 
How to create android applications
How to create android applicationsHow to create android applications
How to create android applications
 
Android
Android Android
Android
 
Android
AndroidAndroid
Android
 
Cs4hs android-01hello
Cs4hs android-01helloCs4hs android-01hello
Cs4hs android-01hello
 
Slite of Mid-term presentation
Slite of Mid-term presentationSlite of Mid-term presentation
Slite of Mid-term presentation
 
Notes Unit2.pptx
Notes Unit2.pptxNotes Unit2.pptx
Notes Unit2.pptx
 
androidPramming.ppt
androidPramming.pptandroidPramming.ppt
androidPramming.ppt
 
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
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 
Ppt of tutorial android app
Ppt of tutorial android appPpt of tutorial android app
Ppt of tutorial android app
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Introduction to Android App Development
Introduction to Android App DevelopmentIntroduction to Android App Development
Introduction to Android App Development
 
Android Stsucture
Android StsuctureAndroid Stsucture
Android Stsucture
 
Android app development ppt
Android app development pptAndroid app development ppt
Android app development ppt
 

More from University of Technology

More from University of Technology (19)

Phương pháp học đại học
Phương pháp học đại họcPhương pháp học đại học
Phương pháp học đại học
 
Basic probability & statistics
Basic probability & statisticsBasic probability & statistics
Basic probability & statistics
 
Training Google Drive and Hangouts.pptx
Training Google Drive and Hangouts.pptxTraining Google Drive and Hangouts.pptx
Training Google Drive and Hangouts.pptx
 
Introduction to gsa vietnam
Introduction to gsa vietnamIntroduction to gsa vietnam
Introduction to gsa vietnam
 
Ubuntu – Linux Useful Commands
Ubuntu – Linux Useful CommandsUbuntu – Linux Useful Commands
Ubuntu – Linux Useful Commands
 
Phuong phap hoc tap on thi 2013
Phuong phap hoc tap on thi 2013Phuong phap hoc tap on thi 2013
Phuong phap hoc tap on thi 2013
 
Training basic latex
Training basic latexTraining basic latex
Training basic latex
 
Wordnet Introduction
Wordnet IntroductionWordnet Introduction
Wordnet Introduction
 
Training python (new Updated)
Training python (new Updated)Training python (new Updated)
Training python (new Updated)
 
Introduction to WEB HTML, CSS
Introduction to WEB HTML, CSSIntroduction to WEB HTML, CSS
Introduction to WEB HTML, CSS
 
Python/Django Training
Python/Django TrainingPython/Django Training
Python/Django Training
 
Design patterns tutorials
Design patterns tutorialsDesign patterns tutorials
Design patterns tutorials
 
Gioi thieu truong bk
Gioi thieu truong bkGioi thieu truong bk
Gioi thieu truong bk
 
Training javascript 2012 hcmut
Training javascript 2012 hcmutTraining javascript 2012 hcmut
Training javascript 2012 hcmut
 
Phương pháp học tập official
Phương pháp học tập officialPhương pháp học tập official
Phương pháp học tập official
 
English Writing Skills
English Writing SkillsEnglish Writing Skills
English Writing Skills
 
Django - basics
Django - basicsDjango - basics
Django - basics
 
Python - the basics
Python - the basicsPython - the basics
Python - the basics
 
Presentation bkit business
Presentation bkit businessPresentation bkit business
Presentation bkit business
 

Recently uploaded

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Recently uploaded (20)

18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

Training android

  • 1. Editor Nguyễn Đức Minh Khôi nguyenducminhkhoi@gmail.com nguyenducminhkhoi.blogspot.com Training Android @HCMC University of Technology Summer 2012
  • 2.
  • 3.
  • 4. Page: 4 Training Android June 2012 Introduction – What is Android? The Android operating system was developed by Android, Inc., Was acquired by Google in July 2005. Developing Android apps is the openness of the platform The operating system is open source and free.
  • 5.
  • 6. Page: 6 Training Android June 2012 Introduction (cont.) Java: was a logical choice for the Android platform enables you to develop apps that will run on a variety of devices without any platform-specific code. is object oriented and has access to powerful class libraries that help you develop apps quickly.
  • 7. Page: 7 Training Android June 2012 Introduction (cont.) XML: enables you to better separate the presentation of your application from the code that controls its behavior. makes it easier to visualize the structure of your UI, so it's easier to debug problems Is similar to HTML
  • 8. Page: 8 Training Android June 2012 Introduction (cont.) Multitouch screen:
  • 9. Page: 9 Training Android June 2012 Introduction (cont.) Android versions: Android 1.6 (Donut) Android 2.0–2.1 (Eclair) Android 2.2 (Froyo) Android 2.3 (Gingerbread) Android 3.0 (Honeycomb) Android 4.0 (Ice Cream Sandwich) Android 5.0 (Jelly Beans) See more at: http://developer.android.com/resources/dashboard/platform -versions.html
  • 10. Page: 10 Training Android June 2012 Introduction (cont.) Types of android apps (go to https://play.google.com/store) for more details Other sites you can download apps:
  • 11. Page: 11 Training Android June 2012 Introduction (cont.)
  • 12. Page: 12 Training Android June 2012 How to set up Software and hardware system requirement: To develop Android apps you need a Windows®, Linux or Mac OS X system. Java SE 5 or higher Software Development Kit Eclipse 3.7 (Indigo) IDE for Java Developers Android SDK versions 2.2, 2.3.3 and 3.x ADT (Android Development Tools) Plugin for Eclipse
  • 13. Page: 13 Training Android June 2012 How to set up (cont.) Install JDK (Java Development Kit) 6: Go to www.oracle.com/technetwork/java/javase/index- 137561.html Install Eclipse IDE Go to www.eclipse.org/downloads Choose Eclipse IDE for Java Developers Install the Android SDK Go to www.developer.android.com/sdk/index.html Click and choose your suitable platform Install ADT plugin for Eclipse Go to www.developer.android.com/sdk/eclipse-adt.html carefully follow the instructions for downloading and installing the ADT Plugin
  • 14. Page: 14 Training Android June 2012 How to set up (cont.) Install Android platform:
  • 15. Page: 15 Training Android June 2012 How to set up (cont.)
  • 16. Page: 16 Training Android June 2012 How to set up (cont.) Creating Android Virtual Device (AVD): The Android emulator, included in the Android SDK, allows you to run Android apps in a simulated environment on your computer rather than on an actual Android device.
  • 17. Page: 17 Training Android June 2012 How to set up (cont.)
  • 18. Page: 18 Training Android June 2012 Source for learning Best resource for learning and referencing: http://developer.android.com/index.html
  • 19. Page: 19 Training Android June 2012 Source for learning (cont.)
  • 20. Page: 20 Training Android June 2012 Source for learning (cont.)
  • 21.
  • 22. Page: 22 Training Android June 2012 Welcome apps (cont.)
  • 23. Page: 23 Training Android June 2012 Eclipse IDE
  • 24. Page: 24 Training Android June 2012 Eclipse IDE (cont.) Create new Project:
  • 25. Page: 25 Training Android June 2012 Eclipse IDE (cont.) Platform Codename API Level Android 1.5 Cupcake 3 Android 1.6 Donut 4 Android 2.1 Eclair 7 Android 2.2 Froyo 8 Android 2.3 - Gingerbread 9 Android 2.3.2 Android 2.3.3 - 10 Android 2.3.7 Android 3.0 Honeycomb 11 Android 3.1 12 Android 3.2 13 Android 4.0 - Ice Cream 14 Android 4.0.2 Sandwich Android 4.0.3 - 15 Android 4.0.4
  • 26. Page: 26 Training Android June 2012 Developing GUI
  • 27. Page: 27 Training Android June 2012 Developing GUI (cont.)
  • 28. Page: 28 Training Android June 2012 Developing GUI (cont.)
  • 29. Page: 29 Training Android June 2012 Developing GUI (cont.)
  • 30. Page: 30 Training Android June 2012 Developing GUI (cont.)
  • 31. Page: 31 Training Android June 2012 Developing GUI (cont.)
  • 32. Page: 32 Training Android June 2012 Running the Welcome apps To run the app in an Android Virtual Device (AVD), right click the app’s root node in the Package Explorer window and select Run As > Android Application.
  • 33. Page: 33 Training Android June 2012 Building Features Each app below will expand on one Class hour By practicing these apps you will learn some interesting features Each app will contain: Introductionsand objectives New Features Building GUI Adding functions Results
  • 34. Page: 34 Training Android June 2012 Building Features Each app below will expand on one Class hour By practicing these apps you will learn some interesting features Each app will contain: Introductionsand objectives Technologies Overview Building GUI Adding functions Results
  • 35. Page: 35 Training Android June 2012 Building Features (cont.) 1.Tip Calculator App 2.Favorite Twitter Searches App 3.Flag Quiz Game App 4.Cannon Game App 5.Spot on Game App 6.Doodlz App 7.Address Book App 8.Slideshow App 9.Enhanced Slideshow App 10.Weather Viewer App
  • 36. Page: 36 Training Android June 2012 Tips Calculator App Objectives: Building an Android App with Java Design a GUI using a TableLayout Directly edit the XML of a GUI layout to customize properties Use Android Activity’s subclass interact with EditTexts, a TextView and a SeekBar.
  • 37. Page: 37 Training Android June 2012 Tips Calculator App (cont.) Introduction: “The Tip Calculator app calculates and displays tips for a restaurant bill. As the user enters a bill total, the app calculates and displays the tip amount and total bill for three common tipping percentages— 10%, 15% and 20%. The user can also specify a custom tip percentage by moving the thumb of a Seekbar—this updates the percentage shown to the right of the Seekbar. The suggested tips and bill totals are updated in response to each user interaction.”
  • 38. Page: 38 Training Android June 2012 Tips Calculator App (cont.) Technologies Overview: TableLayout and TableRow introduction See more at: •www.developer.android.com/reference/android/widget/TableLayout.html •www.developer.android.com/reference/android/widget/TableRow.html
  • 39. Page: 39 Training Android June 2012 Tips Calculator App (cont.) Building GUI: Create GUI with the following information
  • 40. Page: 40 Training Android June 2012 Tips Calculator App (cont.) main.xml describe GUI like figure above String.xml
  • 41. Page: 41 Training Android June 2012 Tips Calculator App (cont.) Adding Functions: Remember when you want to import some library, use just type the name of the class (don’t need to complete) and press (Ctrl + Space), it will import immediately Class Activity of package android.app provides the basic lifecycle methods of an app—we’ll discuss these shortly. Class Bundle of package android.os represents an app’s state information. An app can save its state when it’s sent to the background by the operating system—for example, when the user launches another app or a phone call is received.
  • 42. Page: 42 Training Android June 2012 Tips Calculator App (cont.) Android apps doesn’t have main method four types of components—activities, services, content providers and broadcast receivers A separate activity is typically associated with each screen of an app Throughout its life an activity can be in one of several states—active (or running), paused or stopped. An active (or running) activity is visible on the screen and “has the focus” A paused activity is visible on the screen but doesn’t have the focus. can be killed when its memory is needed by the operating system A stopped activity is not visible on the screen and is likely to be killed by the system when its memory is needed. See more at: www.developer.android.com/reference/android/app/Activity.html
  • 43. Page: 43 Training Android June 2012 Tips Calculator App (cont.) Override method: onCreate: called by the system when an Activity is starting—that is, when its GUI is about to be displayed so that the user can interact with the Activity. onSaveInstanceState: called by the system when the configuration of the device changes during the app’s execution  Remember: Each activity lifecycle method you override must call the superclass’s version of that method first; otherwise, an exception will be thrown when that method is called.
  • 44. Page: 44 Training Android June 2012 Tips Calculator App (cont.) R content class: Class drawable—contains constants for any drawable items, such as images, that you put in the various drawable folders in your app’s res folder Class id—contains constants for the GUI components in your XML layout files Class layout—contains constants that represent each layout file in your project (such as, main.xml) Class string—contains constants for each String in the strings.xml file
  • 45. Page: 45 Training Android June 2012 Tips Calculator App (cont.) Results:
  • 46. Page: 46 Training Android June 2012 Favorite Twitter Searches App Objectives: SharedPreferences, Buttons, Nested Layouts, Intents, AlertDialogs, Inflating XML Layouts and the Manifest File Use a ScrollView to display objects that do not fit on the screen. Programmatically open a website in a web browser by using an Intent. Programmatically hide the soft keyboard.
  • 47. Page: 47 Training Android June 2012 Favorite Twitter Searches App (cont.) Introduction: “The Favorite Twitter Searches app allows users to save their favorite (possibly lengthy) Twitter search strings with easy-to-remember, user-chosen, short tag names. Users can then conveniently follow the tweets on their favorite topics. Twitter search queries can be finely tuned using Twitter’s search operators (dev.twitter.com/docs/using-search)—but more complex queries are lengthy, time consuming and error prone to type on a mobile device. The user’s favorite searches are saved on the device, so they’re immediately available each time the app launches.”
  • 48. Page: 48 Training Android June 2012 Favorite Twitter Searches App (cont.)
  • 49. Page: 49 Training Android June 2012 Favorite Twitter Searches App (cont.) Technologies Overview: ScrollView: is a ViewGroup that can contain other Views (like a layout) and that lets users scroll through content too large to display on the screen. To read the key/value pairs from this file we’ll use SharedPreferences objects (package android.content). To modify the file’s contents, we’ll use SharedPreferences.Editor objects (package android.content). The keys in the file must be Strings, and the values can be Strings or primitive-type values Intents are typically used to launch activities—they indicate an action to be performed and the data on which that action is to be performed. We load the URL into a web browser by creating a new Intent for viewing a URL, then passing that Intent to the startActivity method, which our Activity inherits indirectly from class Context
  • 50. Page: 50 Training Android June 2012 Favorite Twitter Searches App (cont.) New Features: LayoutInflater programmatically creates these GUI components from a predefined XML layout. The LayoutInflater inflates an XML layout file, thus creating the components specified in the XML. You can display messages and confirmations like these with an AlertDialog. We specify the settings for the dialog with an AlertDialog.Builder object, then use it to create the AlertDialog. The AndroidManifest.xml file is created for you when you create an app using the ADT Plugin in Eclipse. This file specifies settings such as the app’s name, the package name, the target and minimum SDKs, the app’s Activity name(s) and more
  • 51. Page: 51 Training Android June 2012 Favorite Twitter Searches App (cont.) Building the GUI:
  • 52. Page: 52 Training Android June 2012 Favorite Twitter Searches App (cont.) Adding functions: Package android.widget contains the widgets (i.e., GUI components) and layouts that are used in Android GUIs. Class Button of package android.widget represents a simple push button that the user touches to get the app to perform a specific action. You implement interface View.OnClickListener of package android.view to specify the code that should execute when the user touches a Button Overridden Method OnCreate of Class Activity, called by system when: when the app loads if the app’s process was killed by the operating system while the app was in the background, and the app is then restored each time the configuration changes, such as when the user rotates the device or opens/closes a physical keyboard.
  • 53. Page: 53 Training Android June 2012 Favorite Twitter Searches App (cont.) Adding functions: Method getSharedPreferences to get a SharedPreferences object that can read tag/query pairs stored previously (if any) from the "searches" file. The first argument indicates the name of the file that contains the data. The second argument specifies the accessibility of the file and can be set to one of the following options: MODE_PRIVATE— The file is accessible only to this app. In most cases, you’ll use this constant as the second argument to getSharedPreferences. MODE_WORLD_READABLE— Any app on the device can read from the file. MODE_WORLD_WRITABLE— Any app on the device can write to the file.
  • 54. Page: 54 Training Android June 2012 Favorite Twitter Searches App (cont.) AndroidManifest.xml For complete information, refer to this page: www.developer.android.com/guide/topics/manifest/manif est-intro.html
  • 55. Page: 55 Training Android June 2012 Favorite Twitter Searches App (cont.)
  • 56. Page: 56 Training Android June 2012 Flag Quiz Game App Objectives: Assets, AssetManager, Tweened Animations, Handler, Menus and Logging Error Messages. Use an AssetManager to get a list of all assets in an app. Use random-number generation to vary flag choices. Use a Drawable to display a flag image in an ImageView. Use a Handler to schedule a future action. Use an ArrayList to hold collections of items and a HashMap to hold name–value pairs. Override Activity’s onCreateOptionsMenu method to create a Menu and MenuItems that enable the user to configure the app’s options. Use Android’s logging mechanism to log error messages.
  • 57. Page: 57 Training Android June 2012 Flag Quiz Game App (cont.) Introduction: “The Flag Quiz Game app tests the user’s ability to correctly identify country flags. Initially, the app presents the user with a flag image and three possible answers—one matches the flag and the others are randomly selected, nonduplicated incorrect answers. The app displays the user’s progress throughout the quiz, showing the question number (out of 10) in a TextView above the current flag image.”
  • 58. Page: 58 Training Android June 2012 Flag Quiz Game App (cont.)
  • 59. Page: 59 Training Android June 2012 Flag Quiz Game App (cont.) Technologies Overview: Using the App’s assets Folder: the assets folder may contain files of any type that can be organized in subfolders—we maintain the flag images for each region in a separate subfolder. Files in the assets folders are accessed via an AssetManager (package android.content.res), which can provide a list of all of the file names in a specified subfolder of assets and can be used to access each asset. Using a Menu to Provide App Options: override Activity’s onCreateOptionsMenu method and add the options to the Menu that the method receives as an argument. Activity method onOptionsItemSelected is called to respond to the selection. Using a Handler to Execute a Runnable in the Future: . Handler method postDelayed receives as arguments a Runnable to execute and a delay in milliseconds.
  • 60. Page: 60 Training Android June 2012 Flag Quiz Game App (cont.) Technologies Overview (cont.): Animating the Flag When an Incorrect Choice Is Touched: AnimationUtils static method loadAnimation to load the animation from an XML file that specifies the animation’s options. We also specify the number of times the animation should repeat with Animation method setRepeatCount and perform the animation by calling View method startAnimation (with the Animation as an argument) on the ImageView. Logging Exception Messages with Log.e: When exceptions occur, you can log them for debugging purposes with Android’s built-in logging mechanism, which uses a circular buffer to store the messages for a short time. Android provides class Log (package android.util) with several static methods that represent messages of varying detail. Java Data Structures: ArrayList<String>, Map<String, Boolean>, Set<String>
  • 61. Page: 61 Training Android June 2012 Flag Quiz Game App (cont.) Building the App GUI: Main.xml Linear Layout
  • 62. Page: 62 Training Android June 2012 Flag Quiz Game App (cont.) colors.xml & dimen.xml:
  • 63. Page: 63 Training Android June 2012 Flag Quiz Game App (cont.) string.xml:
  • 64. Page: 64 Training Android June 2012 Flag Quiz Game App (cont.)
  • 65. Page: 65 Training Android June 2012 Flag Quiz Game App (cont.) Study more: View animations to create a shake effect that consists of three animations in an animation set a collection of animations which make up a larger animation. Animation sets may contain any combination of tweened animations— alpha (transparency), scale (resize), translate (move) and rotate. android:fromXDelta attribute is the View’s offset when the animation starts and the android:toXDelta attribute is the View’s offset when the animation ends. These attributes can have absolute values (in pixels) a percentage of the animated View’s size a percentage of the animated View’s parent’s size The android:duration attribute specifies how long the animation lasts in milliseconds. android:startOffset attribute to specify the number of milliseconds into the future at which an animation should begin.
  • 66. Page: 66 Training Android June 2012 Flag Quiz Game App (cont.) Building the App AndroidManifest.xml:
  • 67. Page: 67 Training Android June 2012 Cannon Game App Objectives: Create a simple game app that’s easy to code and fun to play. Create a custom SurfaceView subclass and use it to display the game’s graphics from a separate thread of execution. Draw graphics using Paints and a Canvas. Override Activity’s onTouchEvent to process touch events when the user touches the screen or drags a finger on the screen. Use a GestureDetector to recognize more sophisticated user touch motions, such as double taps. Perform simple collision detection. Add sound to your app using a SoundPool and the AudioManager. Override three additional Activity lifecycle methods.
  • 68. Page: 68 Training Android June 2012 Cannon Game App (cont.) Introduction: “The Cannon Game app challenges you to destroy a seven- piece target before a ten-second time limit expires. The game consists of four visual components—a cannon that you control, a cannonball, the target and a blocker that defends the target. You aim the cannon by touching the screen—the cannon then aims at the touched point. The cannon fires a cannonball when you double-tap the screen. At the end of the game, the app displays an AlertDialog indicating whether you won or lost, and showing the number of shots fired and the elapsed time”
  • 69. Page: 69 Training Android June 2012 Cannon Game App (cont.)
  • 70. Page: 70 Training Android June 2012 Cannon Game App (cont.)
  • 71. Page: 71 Training Android June 2012 Cannon Game App (cont.) Technologies Overview Defining String Formatting Resources in strings.xml Attaching a Custom View to a Layout Using the Resource Folder raw Activity Lifecycle Methods onPause and onDestroy: Method onPause is called for the current Activity when another activity receives the focus, which sends the current activity to the background. We use onPause to suspend game play so that the game does not continue executing when the user cannot interact with it. When an Activity is shut down, its onDestroy method is called. We use this method to release the app’s sound resources. Overriding Activity Method onTouchEvent
  • 72. Page: 72 Training Android June 2012 Cannon Game App (cont.) Technologies Overview (cont.) GestureDetector and SimpleOnGestureListener: A GestureDetector allows an app to react to more sophisticated user interactions such as flings, double-taps, long presses and scrolls. Your apps can respond to such events by implementing the methods of the GestureDetector. GestureDetector.SimpleOnGestureListener is an adapter class that implements all the methods of these two interfaces, so you can extend this class and override just the method(s) you need from these interfaces. Adding Sound with SoundPool and AudioManager Frame-by-Frame Animation with Threads, SurfaceView and SurfaceHolder Simple Collision Detection Drawing Graphics Using Paint and Canvas
  • 73. Page: 73 Training Android June 2012 Cannon Game App (cont.) Building App’s GUI and resource files:
  • 74. Page: 74 Training Android June 2012 Cannon Game App (cont.) Building App’s GUI and resource files (cont.):
  • 75. Page: 75 Training Android June 2012 Cannon Game App (cont.) Building App’s GUI and resource files (cont.): The notation 1$ in %1$.1f (line 5) indicates that the first argument after the format String should replace the format specifier %1$d. Similarly, %2$.1f indicates that the second argument after the format String should replace the format specifier %2$.1f. Adding functions (regarding to instructors)