Lecture 2 Android Environment ANDArchitecture

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 38

Mobile

Application
Development
Lecture 02
Todays
Agenda
• Introduction to Android Environment
• Setting up Environment
• Application Fundamentals
• Android Platform Architecture
Development Environment
• Java is the most popular language used to develop Android
applications.
• Android devices don’t run .class and .jar files.
• Instead, to improve speed and battery performance
• Android devices use their own optimized formats for compiled
code.
• That means that you can’t use an ordinary Java development
environment
• You also need special tools to convert your compiled code into an
Android format, to deploy them to an Android device, and to let you
debug the app once it’s running
Old Developer
Android Environment
 Eclipse IDE: type code
in,compile, not Android‐
specific

 Android Dev Tools (ADT):


Eclipse
plugin, adds Androidfunctionality

 Android Software Dev


Kit(SDK):
Tools to build, test and run
apps


New Developer
Android Environment
 Google developed it’s own IDEcalled
• Android Studio
 Combines tools in
olddevelopment environment
into 1
 Cleaner interface specifically for
Android Development (e.g. drag and
drop app design)
Android Studio
In December
 will 2014, Google
stop supporting Eclipse
announcedit
IDE
Installing Android
Studio
The most important place to find information and links to
tools is the Android Developers site:
http://developer.android.com
Installing Android
StudioStep 1: Install Java (at least version 1.7)

 Note: You may already have Java installed. Checkfirst
 Can find the JDK at
http://www.oracle.com/technetwork/java/javase/downloads/index.html

 Step 2: Set JAVA_HOME system variable


 This variable tells applications that need Java where it isinstalled

 Step 3: Install Android Studio


https://developer.android.com/studio/install

 Bucky Roberts (thenewboston): nice youtube


Android tutorials
 Tutorial 1: Install Java https://
www.youtube.com/watch?v=QAbQgLGKd3Y
 Tutorial 2: Install Android Studio
Where to Run
AndroidApp
Android app can runon:

 Real phone (or device) Preview phone
 Emulator (software version of pane in Android
Studio
phone)
Emulator Pros and
Cons Pros:

 Conveniently test app on basic hardware by clicking in software


 Easy to test app on various devices (phones, tablets, TVs, etc), various
screen sizes

 Cons:
 Some hardware missing, especially hardware for sensingenvironment

 E.g. GPS, camera, video recording, etc

 Needs a lot of memory to run and eventually slows down the system
Emulator Limitations

 No support for
 Phone calls (calling or receiving)
 USB connections
 Camera/video capture (input)
 Bluetooth
 Sensors, acccelerometer, gyroscope, etc
 Device‐attached headphones
 Determining battery charge level and AC charging
state
 Determining SD cardinsert/eject

 Slow!!!
Running Android App on
RealPhone
 Need USB cord to copy app from development PC to
phone
Setting up your
Project
After installing Android Studio, need to set up your

project
 Tutorial: Android App Development for Beginners ‐ 3
– Setting up your project by Bucky Roberts
(thenewboston)
 https://www.youtube.com/watch?v=r4oIez0sfvY

 Main steps to set up Android Project


 Start a new Android Project
 Configure new Android Project (select app name, domain name,
etc)
 Set platform and minimum SDK
 Add an Activity
Some Question you may have in
mind
What is a
gradle?
• When you click the run button in Android Studio, most of the actual
work is done by an external build tool called Gradle.
• Gradle works behind the scenes to
• Locates and downloads the correct versions of any third-party libraries you
need.
• Calls the correct build tools in the correct sequence to turn all of your source
code and resources into a deployable app.
• Installs and runs your app on an Android device.
• A whole bunch of other stuff, like running tests and checking the quality of
your code.
• Sometimes, however, it’s helpful to dive into Gradle and hack it
manually
Android
Studio
Run
AVDManager
How to Run
theApp? Click here to run the app
Run App on Virtual
Device(Phone)
Tour of Android Studio
Interface
Tutorial 5: Tour of Android Studio Interface [6:01

mins]
 https://www.youtube.com/watch?v=‐pdTqBq2TFQ

 Quick overview of main sections of Android Studio


 Windows menu bar
 Android tool bar
 Project window
 Editor Window
 Palette for Drag‐and‐Drop Design of Android buttons

 More detailed coverage of specific UI aspects later


Typical Windows Menu Bar (File, edit, etc)
Tool Bar: Shortcuts to Frequently used Android-specific
Functions (E.g. One-click access to SDK manager)
Path to Current File in IDE Window
(Clickable)
Editor Window (Allows editting of current file we are working
on)
Clicking on Editor Window Tabs switches between Java code and Visual
Interface
Project Window (Allows between project files, packages,
etc)
Palette of Drag-and-Drop Elements for Designing Interface (Layout, widgets,
etc)
Parameters of Drag-and-Drop Elements for Designing
Interface (e.g. colors, dimensions of widgets, etc)
Importing Existing
Code
 Can also import existingcode
 The text comes with lots of free code you can learn from, use in projects
as starting point
 Can import from gitHubrepository
 See https://developer.android.com/studio/intro/migrate
The
Android
platform
dissected
Application
s
• Android application at the top layer.
• You will write your application to be installed on this layer only.
• Examples of such applications are Contacts Books, Browser, Games
etc.
Application
Framework
• The Application Framework layer provides many higher-level services to
applications in the form of Java classes.
• Application developers are allowed to make use of these services in their
applications.
• The Android framework includes the following key services
• Activity Manager − Controls all aspects of the application lifecycle and activity
stack.
• Content Providers − Allows applications to publish and share data with other
applications.
• Resource Manager − Provides access to non-code embedded resources such as
strings, color settings and user interface layouts.
• Notifications Manager − Allows applications to display alerts and notifications to the
user.
• View System − An extensible set of views used to create application user interfaces.
Application
Framework
• Package Manager: Manages various kinds of information related to
the application packages that are currently installed on the device.

• Telephony Manager: Enables app to use phone capabilities of the


device.

• Location Manager: Deals with location awareness capabilities.


Android
•Runtime
This section provides a key component called Dalvik Virtual Machine which
is a kind of Java Virtual Machine specially designed and optimized for
Android.
• ART is capable of both Ahead-of-time (AOT) and Just-in-time (JIT)
compilation.
• The Dalvik VM makes use of Linux core features
• like memory management and multi-threading, which is intrinsic in the Java
language.
• The Dalvik VM enables every Android application to run in its own process, with its
own instance of the Dalvik virtual machine.
• The Android runtime also provides a set of core libraries which enable
Android application developers to write Android applications using
standard Java programming language.
Android
•Libraries
SQLite Library used for data storage and light in terms of mobile
memory footprints and task execution.
• WebKit Library mainly provides Web Browsing engine and a lot more
related features.
• The surface manager library is responsible for rendering windows and
drawing surfaces of various apps on the screen.
• The media framework library provides media codes for audio and
video.
• The OpenGl (Open Graphics Library) and SGL(Scalable Graphics
Library) are the graphics libraries for 3D and 2D rendering,
respectively.
• The FreeType Library is used for rendering fonts.
Android
Libraries
• This category encompasses those Java-based libraries that are specific
to Android development.
• facilitate user interface building, graphics drawing and database access
• android.app − Provides access to the application model and is the
important part of all Android applications.
• android.content − Facilitates content access, publishing and
messaging between applications and application components.
• android.database − Used to access data published by content
providers and includes SQLite database management classes.
Android
Libraries
• android.opengl − A Java interface to the OpenGL ES 3D graphics rendering
API.
• android.os − Provides applications with access to standard operating
system services including messages, system services and inter-process
communication.
• android.text − Used to render and manipulate text on a device
display.
• android.view − The fundamental building blocks of application user
interfaces.
• android.widget − A rich collection of pre-built user interface components
such as buttons, labels, list views, layout managers, radio buttons etc.
• android.webkit − A set of classes intended to allow web-browsing
capabilities to be built into applications.
Linux
kernel
• This layer is the foundation of the Android Platform.
• Contains all low level drivers for various hardware components support.
• This provides a level of abstraction between the device hardware and it
contains all the essential hardware drivers like camera, keypad, display etc.
• Also, the kernel handles all the things that Linux is really good at such as
networking and a vast array of device drivers, which take the pain out of
interfacing to peripheral hardware
• Android Runtime relies on Linux Kernel for core system services like,
• Memory, process management, threading etc.
• Network stack
• Driver model
• Security and more.

You might also like