Download Introduction to the Web and .NET

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

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

Document related concepts
no text concepts found
Transcript
ANDROID
L. Grewe
What is Android








An open source platform for mobile, embedded and wearable
devices
Google is the principle contributor
HW device manufacturer can customize Android to suite their needs
Android is not an operating system
Android is build on top of Linux Kernel
Android is not equivalent to Linux Kernel
Android is an open source
Android devices sales largest worldwide
Android and Java
•
•
•
Android does not use the standard JVM
Android own its own JVM (Dalvik)
Android Dalvik vs standard JVM
o register-based vs stack-based
o more efficient and compact implementation
o different set of java libraries than standard java libraries
Android and Java
o
cannot run standard Java
bytecode on Android.
o
provides a tool "dx" which allows
to convert Java Class files into
"dex" (Dalvik Executable) files.
o
Android applications are packed
into an .apk (Android Package)
file by the APK Packager
o
o
signs your APK using either the debug or
release keystore.
This is all done for you with the
main Android Studio IDE
Debug version (app intend only for testing) , signs with the Defualt debug keystore auto created by Android Studio
Release version  signs your app with the release keystore. To create a release keystore, read about SIGNING APP IN ANDROID STUDIO
Android FrameWork Stack
Android Versions


API evolves over time
Devices typically after some time are Out of Date –
do not allow updates to new Android version –force
buying of new hardware (like Apple)
Android Application can use 3rd party
resources…
•
Android applications
o google maps
o facebook
o twitter
o ...MORE
AndroidSDK
•
•
•
•
Tools
Docs
Platforms
o Android XX
 Data
 Skins
 Images
 Samples
Add-ons
o Google API
Android Framework
•
•
•
•
•
•
ActivityManager
Content providers
Resource manager
Location Manager
Notification Manager
...MORE
Android Process and Thread
•
Linux process per application
•
•
•
Runs under its own userid which is generated automatically by Android
system during deployment
Hence application isolated from other applications
One thread per process
o UI Thread
o manage Looper message
Android Application Components: Android
application =collection of loosely coupled components
•
Activity (and fragments)
•
•
•
•
Views
Service
Intents and Broadcast receiver (Intents reciever)
Content provider
Application = LOOSELY coupled
components
Activity


presentation layer , e.g. a screen which the user sees.
application can have several activities and it can be switched
between them during runtime of the application.

Also, fragments –like mini-activies grouped together to create an
activity
Activity
•
•
•
•
The building block of the user interface.
The Android analogue for the window or
dialog in a desktop application.
a single, focused thing that the user can do
takes care of creating a window for user
presentation to the user
o full-screen windows
o floating windows
o embedding inside of another activity
Lifecycle events will invoke the methods of Activity:
o void onCreate(Bundle savedInstanceState)
o void onStart()
o void onRestart()
o void onResume()
o void onPause()
o void onStop()
o void onDestroy()
Android Activity LifeCycle
Views
NOTE: this is really contained in Activity or Fragments
and those not really a separate “component” of app
The User interface of an
Activities is build with
widgets classes which
inherent from
"android.view.View".
 The layout of the views is
managed by
"android.view.ViewGroups".

Services

perform background tasks without providing an
UI.
 Usefull
when your app must communicate with backend systems
and not make your user wait for it to finish
 Useful when you app has to do a lot of long calculations and
don’t want your user to wail
can notify the user via the notification framework
in Android.
 An example --- Pandora App –a music app that
can run in background and still play music

Service
•
•
•
•
•
•
•

perform a longer-running operation
while not interacting with the user
can be started and stopped
doesn't have UI
run by activities
implicit Service (binding service)
explicit Service (start service)
lifecycle
o void onCreate()
o void onStart(Intent intent)
o void onDestroy()
Examples:


checking for updates to an RSS feed
playing back music even if the controlling activity is no longer operating.
Content Provider
•
store and retrieve data and make it accessible
to all applications
•
to share data across applications
•
Android contains a SQLite DB which can serve as data provider
•
You can use pre-existing content-providers or you could create an
app that itself is a content provider for other applications to use.
•
Think about how some apps use your contact list ---this contact list
is a content provider that is built-in/existing already for you to use
in your application.
•
•
•
Intents
an abstract description of an operation to be performed
o action
o data
Explicit Intents (specified a component)
Implicit Intents
This may be a new idea for you --- it is a
asynchronous way of telling the Android
System you want to do something
We will learn more later about what this
means
Intents

Intents are system (asynchronous) messages, running around the inside of the device,
notifying applications of various events,

hardware state changes (e.g., an SD card was inserted),

incoming data (e.g., an SMS message arrived),

application events (e.g., your activity was launched from the device's main menu).

are asynchronous messages which allow the application to request functionality
from other services or activities. An application can call directly a service or
activity (explicit intent) or ask the Android system for registered services and
applications for an intent (implicit intents). For example the application could ask
via an intent for a contact application. Application register themself to an intent
via an IntentFilter. Intents are a powerful concept as they allow to create loosely
coupled applications.
Intents – Explicit, Implicit
An application can call directly a service or
activity (explicit intent)
 An application can ask the Android system for
registered services and applications for an
intent (implicit intents).

You will
NOT understand
this YET—we have
a lecture and will
do some coding
LATER
Intents - Example
the application could ask via an intent for a
contact application.
 Application register themself to an intent via
an IntentFilter.
 Intents are a powerful concept as they allow to
create loosely coupled applications.

How to create Intents

You can receive and respond to intents by
 intent
filters specification
 intent/broadcast receivers

You can create your own intents to
 launch
other activities,
 let you know when specific situations arise (e.g.,
raise an intent when the user gets within 100
meters of a specified location)
Android Broadcast Receiver (Intents
receiver)
receive intents sent by sendBroadcast()
two type of broadcasts
o Normal broadcast
o Ordered broadcast
•
•
o
An application can register as a broadcast receiver for certain
events and can be started if such an event occurs.
HOW do we making an Android
App????

Use current Development tools
Development Tools


Use Android Studio
WITH Android SDK
Development Tools

SDK Manager
 SDK
tools, platforms, and other components into packages
for easy access and management
 for downloading platforms, Google APIs, etc., –

AVD(Android Virtual Devices) Manager

provides a GUI in which you can create and manage AVDs,
which are required by the Android

Emulator

Dalvik Debug Monitor Server
Delivering your application


.apk files: compressed files class byte code
resources( icons, sounds, etc).
All .apks are signed
 Default
development key is created by SDK. When
updating an application, signature are checked.
Installing an application




Basically will be putting the application’s apk on
your hardware
Option 1: from Google play store or similar
Option 2: we will learn how to deploy your app
directly from AndroidStudio to your hardware for
testing
Option 3: to Install to local computer

(on command line –assuming in directory where apk is
located)
adb install whateverName.apk
future


We will learn more about what all of these main
components of an Android Application are slowly --so you will understand through the creation of apps
themselves.
We will begin with creating a very simple
application