Upload
joseph-kandi
View
842
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Learn the core Android App development concepts beyond creating the Android App. We used the Yamba app from the Learning Android demonstrate the use of Android Activities, Services, Broadcast Receivers, Intents and Content Providers.
Citation preview
Android App Development Beyond The HelloWorld App
Cape Town Android MeetupJoseph Kandi
Peruzal Android App Development Training Team
www.peruzal.co.za
Take Aways
!Android Development Environment Android Application Components Threads in Android Designing Android UIs in XML Using Intents Performing Web Service Calls
Android Development Environment
• Java
• Eclipse | Android Studio
• Android SDK
Java Skill Level
• Variables
• Operators
• String
• Loops
• Methods
• Class
• Static
• Inheritance
• Packages and Import
• Access Levels
• Constants
• Interface
• Inheritance
• Abstract
• Generics
• Casting
• Threads
• Enum
• Exception Handling
• Boxing and UnBoxing
Android and Java
Android Software Stack
Custom Linux 2.6 kernel
SQLite, WebKit, SSL, OpenGL ES, Media
Framework
Content Providers, Activity Manager, Window Manager, View
System, Notification System, Telephony Home, Contacts, Browser,
Yamba
Inside Android
System partition
Use command adb shell to logon to the device
Note the permissions on the folders
sdcard
Android Versions and API Level
Get Java
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Eclipse
http://developer.android.com/sdk/index.html
Download from this link
Android Studio
Still buggy, not ideal for beginners to Android development
Download from here
Building Blocks
Activities Services Content Providers Broadcast Receivers Application
Activity
An activity is a single, focused thing that the user can do.
Activity Life Cycle
Activity Class
Called the activity is first created
Called when the activity is becoming visible to the user
Called after the activity has been stopped, prior to it being
started again
Called when the activity will start interacting with the user
Called when the system is about to start resuming a
previous activity Called when activity is no longer visible
Final call before the activity is destroyed
Intents
Messages sent among the major building blocks. They trigger an action to start up, tell a service to start or stop, or simple
broadcast
Services
Services run in the background and don’t have a user interface components
Content Providers
Interfaces for sharing data
Broadcast Receivers
Android implementation of publish/subscribe mechanism or the Observer pattern
Application Context
Refers to the application environment and the process within which all the components are running !
Used to share data between components
Context.getApplicationContext
Activity.getApplication
Android User Interface
Java - done in code XML - declarative
Views
Android organizes its UI into layout and views
Write the xml
Load the XML Resource
Layouts
Example Linear Layout
Also called match_parent
Either
Relative Example
Creating a New Project
• Walkthrough, create a new project
Choose New Project
The name of the appProject Name - NB No spaces allowed
Package name, usually reverse dns of your company name
Minimum supported SDK the app will run on
The version of Android we are
building forDoes not do anything,
ignore
Create an initial activity
Customize the launcher
Preview of the launch icon on different screen resolutions
Path for the image used as a launch icon on the home screen
Choose Activity Type
Choose different activity types
Choose “Blank Activity” here
Choose Main Activity Name
Leave it as MainActivity for now, in future we will change it
The xml file defining the user interface for our
activity
Leave as is
Project Structure
Main activity created during project
setup
Resource folders go under “res” folder
xml layout file defining the screen for
the app
Explains what application consists, the main building
blocks, permissions
AndroidMainfest.xml
Package name for the application
Android SDK
Activity declaration
Main activity action
Intent Category of the action
Layout xmlLive preview
xml defining the UI
File lives under “layout” resource folder
Layout container
xml properties
View component
Main Activity xml file
Java file
Extends Activity class
Using the class R to point to the layout
R file | Auto-generated
R.layout.activity_main, referring to the file under /layout/activity_main.xml
strings.xml
Key used to retrieve the string
Value
AVD | Android Virtual Device Launch AVD manager
Launch AVD manager
AVD ManagerAVD images
Available devices, need at least one to test the app
Add a new AVD
Create a New AVD
Choose name, no spaces allowed
Choose device specifications
Camera support
Amount of RAM
Improves speed of the emulator
Android SDK version
User Interface and Controls
• Project Overview
Project Overview
Yamba App Context
TwitterService
StatusActivity
poststatusupdate
1
Status Activity
Timeline Activity
Action Bar | Menu
Preferences