Download Course Outline (after midterm)

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Course Outline (after midterm)
•
•
•
•
•
•
Introduction
Resources and Layout
Alternative Resources
Activity
Local Database (x2)
Remote Database (x2)
Introduction to Android
Outline
•
•
•
•
•
Overview of the Android
Deploying application packages
Development tools
Step-by-step application development
Lab Exercise
Overview of the Android
• Linux-based OS for mobile devices
• History
– founded by Andy Rubin (2003), owned by Google
(2005), Open Handset Alliance (2007) - Open
source mobile platform
– In 2008 - release of the first phone to use Android
• HTC Dream (also known as the T-Mobile G1)
– High market share
Market Share
Android Architecture
• Android is a software stack for developing
mobile devices
Location Manager
Notification Manager
View System
View System
Dalvik Virtual Machine
• Dalvik Virtual Machine
Executing the Dalvik Executable (.dex) format
.dex format is optimized for minimal memory footprint.
Compilation
Package in .apk files to android devices
Android Versioning
• Platform version in class
– 4.4.2 KitKat (codename = 22)
– http://developer.android.com
• SDK Manager to manage version
– Each version has an API level
Development Tools
• Install Java SDK
• Install Android SDK
• IDE tools
– Android Studio
– Eclipse
• Install ADT Plug-ins (Android development tools)
–
–
–
–
Class Library
Developer Tools
Emulator and System Images
Documentation and Sample Code
Step-by-Step
• Create HelloWorld Application
– File..New..Android Application Project
– Follow the step
• Beware of choosing target API with compile API
UI screen
• Layout file
– The XML file is translated into a View instance
• In Android, all UI elements are Views (or inherit from the
View class) – it’s kind of like JComponent in Swing.
• Activity
– Typically correspond to one UI screen
• A java class that control how UI functions
– The Activity class has a method called setContentView
which sets the layout that will be displayed in the
Activity.
Layout
• xml file that describes how to layout a set of
window components.
• e.g. chesslayout.xml
• <LinearLayout …>
• <ImageView …> </ImageView >
• <TextView …> </TextView>
• <TextView …> </TextView>
• </LinearLayout>
Structure
•
src/
– Your Java files for your application go here in subdirectories.
•
gen/
– Contains Java files automatically generated such as your R.java file.
•
res/
– Contains app resources, such as images, layout files, string values.
•
assets/ Optional
– You can use it to store other raw asset files.
•
Bin/
– Results of building a project
•
AndroidManifest.xml
– Describes the contents of your application.
•
default.properties
– This file contains Android project settings.
Resource
• In Android, anything that is not pure code is
written in a separate resource file (not a java
file), for example strings, images, etc.
– enables easier multi-language support
Res folder
• Resource files are saved as XML
file
• The Resource Complier generates
a Java file which reference the data
in these XML files.
– called R.java
• Using this file you can access the
data in java code
– For example, R.Layout.Button1;
Images and layouts
• Resources IDs automatically generated in R.java
•
•
chesslayout.xml
bishop.png
in res/layout
in res/drawable
• Entries in R.java magically appear.
Don’t control or care about the actual integer values.
•
•
•
• gen/game/chess/R.java
public final class R {
public static final class drawable {
public static final int bishop=0x7f020002;
• Your Java code…
•
setContentView(R.layout.chesslayout);
•
mBishop = getDrawable(R.drawable.bishop);
5/24/2017
Hands-On-Tutorial, Loeb & Angrave 2010
20
Running Emulator
• Go to Android Virtual Device Manager
– Click create and then start if finishes
AVD Manager
• An Android Virtual Device (AVD) is an emulator
configuration that lets you model an actual device by
defining hardware and software options to be
emulated by the Android Emulator.
• Select Window > Android Virtual Device Manager, or
click the AVD Manager icon in the toolbar
• Emulator Command
http://developer.android.com/tools/help/emulator.ht
ml
Accessing layout elements from
Activity
Use findViewById
R.id.name corresponds to
the name given in the xml
file
Event Listener