Android-Dev-Presentation@Trinity College - WordPress.com

knapsackyarnMobile - sans fil

14 déc. 2013 (il y a 3 années et 5 mois)

199 vue(s)

Android Development
javier.loriente@innerfunction.com
www.innerfunction.com
2
Overview

Introduction : innerfunction.com

Introduction to Android:

What is Android

Android features

Architecture

Android building blocks

QR tags : 0x1f.ie service.

Assignment proposals.
3
Innerfunction.com

Javier Loriente (CTO)

javier.loriente@innerfunction.com

http://innerfunction.com

http://doit-mobile.com

Specialized in web & mobile tech.

Java, php, js, nodejs, couchdb

Iphone and Android dev.

Mobile web development : phonegap, jqtouch.
4
What is Android?

Complete software stack for mobile devices:

Mobile Operative System : Linux based.

Middelware.

Set core applications.

Developed by Google and the Open Handset Alliance.

Run in a large number of devices. HTC, Samsung, LG...

Open Source and open app market.

The Android SDK provide all tools and API's to develop
app.

ADT Eclipse plugin make your life even easier...
5
Android Features

Application Framework : Reuse of components (*)

Virtual Machine : Darvik

Integrated Browser

Optimized graphics : 2D, openGL

Database : SQLite

Media support : MPEG4, H.264, MP3, JPG, PNG, GIF...

GSM telephony

Connectivity : Bluethooth, EDGE, 3G and WiFi

Camera, GPS, compass and accelerometer
6
Android Architecture

Core Java Apps :
like email client, SMS, calendar, maps...

Application Framework

Developers can use device hardware. E.g. access location, set
alarms, send notifications...

Full access to same API's than core apps.

Simplify the reuse of components : App can publish capabilities,
other app can use them

Set of C/C++ Libraries :


Exposed through the Application Framework

Android Runtime : Dalvik VM

Linux Kernel : Security, memory and processes management,
network stack, driver model
7
Android Architecture
8
Application Framework:
Components

Views System:

List, grids, boxes, buttons, embedded web browser...

Content providers :

Enable data sharing between apps

Resource Manager :

Provides access to non code resources:


localized strings, graphics, layouts

Notification Manager :

Display alerts in status bar

Activity Manager :

Manage apps life cycle and common navigation stack.
9
Android building blocks

We cover in this presentation:

AndroidManifest.xml

Activities

Intents

Views/Layouts

Resources management

Simulator
10
The Manifest file

Declare all the app components

XML file named :
AndroidManifest.xml

Components : code + files + resources


Declare all the app components

XML file named :
AndroidManifest.xml

Components : code + files + resources


Declare all the app components

XML file named :
AndroidManifest.xml

Components : code + files + resources
<?xml version="1.0" encoding="utf-8"?>
<manifest . . . >

<application . . . >

<activity android:name="com.example.project.FreneticActivity"

android:icon="@drawable/small_pic.png"

android:label="@string/freneticLabel"

. . . >

</activity>

. . .

</application>
</manifest>
11
AndroidManifest.xml
12
Activity

An activity is a single user
screen.

Single thing that the user can
do.

Subclass of Activity base class.

Use an hierarchy of views to
define UI.

Layouts
13
14
Intents

Components get activated with async messages.

An Intent is an object that holds the content of message.

Description of an operation to be performed:

App navigation, send email, make call , view
contact...

Separate methods to activate different components:

Activity:

Context.startActivity() or Context.startActivityForResult()

Service :

Context.startService() or Context.bindService()

Broadcast :

Context.startBroadcast()
15
Intent : Bundle of information

COMPONENT NAME (optional):
Name of component to handle
the intent.

Ex: com.example.project.app.MainActivity

ACTION :
The general action to be performed. Eg:
ACTION_VIEW,
ACTION_CALL, ACTION_EDIT

DATA :
URI data to be acted on, and the data MIME type.

CATEGORY :
Additional info about kind of component to handle
the intent. Ex:
CATEGORY_BROWSABLE, CATEGORY_GADGET,
CATEGORY_HOME

EXTRAS/FLAGS
16
Intents resolution

Two kind of intents:

Explicit intents : Designate target by its name

Implicit intents :

Don't name a target.

Android has to find best component to handle
request.

Compare the content of intent with intents filters.

Based on : action + data (URI+type) + category
Intent openMainSreenIntent = new Intent(this, StartActivity.class);
startActivityForResult(openMainSreenIntent, 1);
17
Intent filters

Activities, services and broadcast receivers can have one or
more intent filters.

A component has separate filters for each job it can do.
18
Intent examples

Intent to start a phone call:

Intent to edit a contact from phonebook :

Intent to scan a QR tag?
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + "001230012")));
startActivity(new Intent(Intent.ACTION_EDIT), “content://contacts/people/1” ));
http://www.openintents.org/
19
Layouts

Layout is architecture for designing
UI inside an activity.

Layout can be declared in two ways:

Declare layout in XML

Instantiate elements at runtime
20
Layout examples
21
Layout
code
example
22
Resources Management

Android manages access to non
code resources:

Layouts, localized strings,
graphics...

Examples:

setContentView(R.layout.main);


<
TextView
android:id
=
"@+id/topbarLabel"
android:text
=
"@string/join_telemote_t
op_bar"
style
=
"@style/TeliaTopBar"

/>
23
24
Development environment
25
QR tag

QR tags are 2 dimensional bar codes used to
encode URLs.

They are readable by QR scanners, mobile
phones with a camera, and smartphones.

The code consists of black modules arranged
in a square pattern on white background.

The information encoded can be text, URL or
other data.
26
0x1f.ie

0x1f is a URL shortening and
QR tag generation service.

This service allows customers
to generate QR tags for
referencing their web pages.

0x1f service generates compact,
reliable tags by shortening the
URL being encoded.

RESTful api.
http://0x1f.ie/h95w5
27
0x1f.ie tags examples
http://admin.0x1f.ie/?
url=http://innerfunction.com/&tagType=greenYellowPng:L&domain=trinity&digest=SvaijRme
s32DZ2dwof14eSP8vDVJm6AN1+KbCKTNwXVTiQ%3D
http://admin.0x1f.ie/?
url=http://innerfunction.com/&tagType=blackWhitePng:L&domain=trinity&digest=SvaijRme
s32DZD2dwo8vDVJm6AN1+KbCKTNwXVTiQ%3D
28
Android Bluetooth

Android includes full support for the Bluetooth network stack.

Android Bluetooth API :


An Android app can:

Scan for bluetooth devices

Query local Bluetooth adapter for paired devices

Establish communication channels

Connect to other devices through service descovery.

Transfer data to other devices

Manage multiple connection
http://developer.android.com/guide/topics/wireless/bluetooth.html
29
Assignment proposals

Android app

Bluetooth

Social networking

QR tags :

Encoding/decoding

0x1f.ie

Localization services
30
Questions?

Links:

http://developer.android.com/

http://www.openintents.org/

For further info, contact me :

javier.loriente@innerfunction.com

jloriente@gmail.com

Twitter: @JavierLoriente