SlideShare uma empresa Scribd logo
1 de 145
Android Code Camp, Urbino — 2012.

Benvenuti.


Android
Code Camp
Android Code Camp, Urbino — 2012.

Theory overview.
The smartphone market.
The Android project.
Android architecture.
The ecosystem.
Application overview.
Structure of an Android project.
Hands-on: setting up the development
  environment.
„Hello World.―
Android Code Camp, Urbino — 2012.

Mobile market.
The smartphone market.

Numbers and growth.
The Android market.
Activations.
Application marketplace.
Fragmentation.
Android Code Camp, Urbino — 2012.

The smartphone market.
433 milions of units in 2011.
616 milions of units forecast for 2012.

• Market growth (contractino of feature
  phone sales).
• Product obsolescence.

Tablets: 320 milions of units in 2015.
Android Code Camp, Urbino — 2012.

   The smartphone market.
                                            2011
                               2.5    3.9

          18.3


                                                                                50.8




12.5




                 20.4



           Android      iOS   BlackBerry     Symbian   Windows Phone   Others
Android Code Camp, Urbino — 2012.

The smartphone market.
                                       2012
                            5.4       3.6
                   6.8
           7.4



26




                                                                               104.8




        Android   iOS    BlackBerry         Symbian   Windows Phone   Others
Android Code Camp, Urbino — 2012.

The Android market.
Astounding growth (+106% forecast).

Mainly Samsung devices:
    Up to 33% of all devices.

2012:
500 milions of devices activated.
1.3 milions of peak activations per day.
Android Code Camp, Urbino — 2012.
Android Code Camp, Urbino — 2012.

Application market.
Android < iOS:
    More than 400.000 applications,
    against 500.000 apps for iOS.

• Google Play
• Amazon AppStore for Android
• Other stores: GetJar, AppBrain, etc.
Android Code Camp, Urbino — 2012.

Application market.
Android < iOS:
    Only ¼ of revenue, on average.
    Different market segment / users.

       Almost 70% of applications are free
       or follow the freemium model
       (against 50% on iOS).

       The fragmentation issue.
Android Code Camp, Urbino — 2012.

Fragmentation.
Android Code Camp, Urbino — 2012.

Fragmentation.
Android Code Camp, Urbino — 2012.

Android.
Google‘s mobile OS.

History.
Versions and evolution.
The open-source project.
Android Code Camp, Urbino — 2012.

A short history of Android.
2003: Andy Rubin founds ―Android Inc‖.
       “...smarter mobile devices that are more aware of
         its owner's location and preferences.”


2004: Apple starts ―Project Purple‖,
    a secret project with AT&T.

2005: Google buys out Android Inc and
    continues the devlopment of the OS.
Android Code Camp, Urbino — 2012.

A short history of Android.
2007, jan: Apple releases the first iPhone.

2007, nov: Google, HTC, Samsung reveal
    the Open Handset Alliance & Android.

2008: first Android phone:
    HTC Dream (G1).
Android Code Camp, Urbino — 2012.

Android versions.
 Year    Version Codename
 2008        1.0 n/a
 2009        1.1 Petit Four
             1.5 Cupcake
             1.6 Donut
             2.0 Eclair
 2010        2.2 Froyo (Frozen Yogurt)
             2.3 Gingerbread
 2011        3.0 Honeycomb
             4.0 Ice Cream Sandwich
 2012        4.1 Jelly Bean
     ?       4.2 K…?
Android Code Camp, Urbino — 2012.

       Android versions.

                                                 1.5
                                                 Soft keyboard, clipboard,
                                                 video…




1.6
Resolution independence



                                    2.0
                                    Maps,
                                    Navigation
Android Code Camp, Urbino — 2012.

Android versions.
                           3.0
                           Digital style, tablet optimization




                                           4.0
                     Halo theme, Project Butter
                           Google Now, Roboto
Android Code Camp, Urbino — 2012.

Android: openness.
October 2010, Steve Jobs:

               „Google likes to characterize
               Android as open and iOS as
               closed. We think this is
               disingenuous. […] The real
               difference is integrated
               versus fragmented.”
Android Code Camp, Urbino — 2012.

Android: openness.
Android Code Camp, Urbino — 2012.

Android: open-source project.
The code of Android is available under
„free― and „open-source― licenses.

Linux kernel (Open Handset Alliance):
     GNU GPL v2, public development.

Android system (Google):
    Network, telephony, Google apps.
    Apache License v2.0, private.
Android Code Camp, Urbino — 2012.

Android: open-source project.
Production of a „flagship phone― by Google
(Nexus), is followed by release of code
(and OEM phones).

Google Play is available on certification.

„Honeycomb incident― (2011).

License is incompatible with GPL (FSF).
Android Code Camp, Urbino — 2012.

The architecture.
Operating System architecture

Linux Kernel.
Native libraries.
Android Runtime.
  Dalvik Virtual Machine.
  Core Libraries.
Application framework.
Application layer.
Android Code Camp, Urbino — 2012.

The architecture.
Android Code Camp, Urbino — 2012.

Linux Kernel.
Kernel 2.6+.

Used for process and thread
management, low-level memory
management, the network
stack, security, for the driver model.
Android Code Camp, Urbino — 2012.

    Native libraries.
    C/C++ libraries executed on top of the
    Linux kernel and used in many fields of the
    Android system.

They expose a lot of funcionalities to
developers through the application
framework.
Android Code Camp, Urbino — 2012.

Android Runtime.
It makes an Android device much different
from a mobile Linux implementation.

Combining the Dalvik Virtual Machine and
the Core Libraries makes possible the
execution of Android applications.
Android Code Camp, Urbino — 2012.

Virtual machine.
Software implementation of a machine
(with a defined Instruction Set Architecture)
that executes programs like a physical
machine.

Virtualization: simulation of an environment
where Guest ISA and Host ISA match.
Emulation: simulation of an environment
where Guest ISA and Host ISA are
different.
Android Code Camp, Urbino — 2012.

Java virtual machine.
Virtual machine that executes programs
written in byte-code: intermediate
rappresentation between machine
language and Java source code.

JVM is an Oracle (ex Sun) specification.

Main implementations:
HotSpot – OpenJDK (GPL).
HotSpot – OracleJDK.
Android Code Camp, Urbino — 2012.

Dalvik virtual machine.
Virtual machine that executes .dex (Dalvik
Executable) files.

Java source code compiled in .class files
and converted to .dex format.

Each Android application runs in a
separate process within its Dalvik virtual
machine instance.

JIT compiler (since version 2.2).
Android Code Camp, Urbino — 2012.

Dalvik vs. JVM.
Dalvik < JVM.
But it is a multidimensional problem.

• Register-based.
• Efficient with multiple VMs.
• Minimum
  memory
  footprint.
• Small
  startup time.
Android Code Camp, Urbino — 2012.

Core libraries.
Dalvik does not comply with either the
J2SE specifications, nor the J2ME.

Core libraries provide most of the
functionalities available through the Java
libraries, as well as Android specific
libraries.
Android Code Camp, Urbino — 2012.

Application framework.
Provides key services, encapsulated in
Java objects, to the applications of the
above level.

These services are available for both
system applications and for third party
applications.
Android Code Camp, Urbino — 2012.

Application layer.
User level applications written in Java
language.


                                     System app
                                           =
                                    Third party App
Android Code Camp, Urbino — 2012.

The ecosystem.
Development ecosystem.

Android SDK.
Eclipse IDE.
Application Programming Interfaces.
Android Code Camp, Urbino — 2012.

SDK: emulator.
Software that emulates the function and
appearance of a virtual hardware
configuration (AVD: Android Virtual
Device).
Android Code Camp, Urbino — 2012.

SDK: emulator.
User-friendly interface to configure AVDs.
Android Code Camp, Urbino — 2012.

SDK: tools.
Logcat: collects logs of an Android device.

Lint: static analisys to optimize and detect
common mistakes.

Proguard: reduce binary size, optimize
and obscure given code. It makes
applications faster and more resilient to
reverse engineering.
Android Code Camp, Urbino — 2012.

SDK: Dalvik Debug Monitor Serve
Debugging tool for Android devices:
gathers information about
processes, threads, heap, logcat and
supports event emulation.
Android Code Camp, Urbino — 2012.

SDK: Android Developer Tools.
Plugin for the Eclipse IDE.
It simplifies the creation, compilation and
maintenance of projects.
It integrates development tools.
It includes graphical editors and
documentation.
Android Code Camp, Urbino — 2012.

Eclipse.
Open-source development
environment,
multi-platform and
multi-language.

It is the reference
platform for Android.

Alternatives:
ANT, NetBeans…
Android Code Camp, Urbino — 2012.

Android APIs.
Android Code Camp, Urbino — 2012.

Android 1.5, API 3.
Playback and audio/video capture.
Speech recognition.
Widgets.
Notifications.
WebView.
Android Code Camp, Urbino — 2012.

Android 1.6, API 4.
Gestures.

Speech synthetizer.

CDMA support.

Variable size and density screens support.
Android Code Camp, Urbino — 2012.

Android 2.1, API 7.
Bluetooth 2.1 support.

Live Wallpapers.
Android Code Camp, Urbino — 2012.

Android 2.2, API 8.
JIT compiler.

SD card installation support.
Speech recognition improvement and third
party openness.
Flash technology support.
Android Code Camp, Urbino — 2012.

Android 2.3, API 9/10.
Native Voip support (SIP).

NFC support.

Concurrent Garbage Collector.

Improved media format support.
Android Code Camp, Urbino — 2012.

Android 3.0, API 11.
Fragments.

ActionBar.

New drag ‗n drop APIs.

2D hardware acceleration support.

New 3D framework renderscript.

Improved media format support.
Android Code Camp, Urbino — 2012.

Android 3.1, API 12.
USB peripherals support.

Resizable Widgets.

Improved media format support.
Android Code Camp, Urbino — 2012.

Android 4.0.1, API 14.
Smartphone and Tablet merge.
Linux kernel 3.x.
Redesigned UI to enhance coherence and
unification.
More powerful notifications.
Continuous speech recognition support.
Social APIs.
Low level streaming APIs.
Android Code Camp, Urbino — 2012.

Android 4.1.3, API 16.
Project Butter.
Expandable notifications.
Improved social APIs.
Advanced speech recognition.
Enhanced speech synthetizer.
Google Now.
Flash technology pulled out.
Android Code Camp, Urbino — 2012.

Applications overview.
Components of an application.

Activity.
Service.
Content provider.
Broadcast receiver.
Intent.
Widget.
Fragment.
Notification.
Android Code Camp, Urbino — 2012.

Activity.
Each activity represents one fullscreen
window.
Android Code Camp, Urbino — 2012.

Activity.
Each activity should be used as an atomic
action of the user.
Android Code Camp, Urbino — 2012.

Activity.
Some activities could have a returning
value.
Android Code Camp, Urbino — 2012.

Activity.
Activities are probably the most
fundamental parts of an app!
We are going to return on it…
Android Code Camp, Urbino — 2012.

Applications overview.
Components of an application.

Activity.
Service.
Content provider.
Broadcast receiver.
Intent.
Widget.
Fragment.
Notification.
Android Code Camp, Urbino — 2012.

Service.
A task the app or the system does without
directly affecting the UI (a background
task).

Examples:
    Gathering data from the system.
    Updating data of an app.
    Download new RSS feeds from a
    server.
Android Code Camp, Urbino — 2012.

Service.
It cannot directly communicate with the
user. Though it can exchange data with
activities (which may belong to the same
app or not) and the system.
Android Code Camp, Urbino — 2012.

Service.
If a particular service should never be
killed by the system, it should be declared
as a foreground service.
Android Code Camp, Urbino — 2012.

Applications overview.
Components of an application.

Activity.
Service.
Content provider.
Broadcast receiver.
Intent.
Widget.
Fragment.
Notification.
Android Code Camp, Urbino — 2012.

Content provider.
• It‘s an abstraction of a set of structured
  data.
• Implements the CRUD interface
  (create, retrieve, update, and delete).
• Can be also used to share data among
  different applications.

Android provides many ready-made
providers. It is also possible to implement
custom providers.
Android Code Camp, Urbino — 2012.

Content provider.
Some examples:

•   List of contacts.
•   List of images on the device.
•   Data from a DB SQLite.
•   Data from a web service.
Android Code Camp, Urbino — 2012.

Applications overview.
Components of an application.

Activity.
Service.
Content provider.
Broadcast receiver.
Intent.
Widget.
Fragment.
Notification.
Android Code Camp, Urbino — 2012.

Broadcast receiver.
Components which are employed for
intra-application / inter-process
communication.

They receive so-called broadcast intents…
Android Code Camp, Urbino — 2012.

Intent.
Are the messaging system between
various components of the system.

Each intent represents a structure which
encapsulates data of a message.
An intent can be thought as an abstraction
of:
     An operation to execute.
     An event which has just happened.
Android Code Camp, Urbino — 2012.

Intent.
Possible values:
Field                     Value
Component name            it.uniurb.codecamp.test
Action                    ACTION_CALL
Data
  URI                     tel:07224475
  Type                    integer
Category                  CATEGORY_LAUNCHER
Extras                    "tel_number":int
Flags                     FLAG_ACTIVITY_SINGLE_TOP
Android Code Camp, Urbino — 2012.

Intent.
Send an image:
Field          Value
Action         SEND
Data           content://media/external/pic16


Show a spot by Google Maps:
Field          Value
Action         VIEW
Data           geo:latitude,longitude?z=zoom
Android Code Camp, Urbino — 2012.

Intent.
The sender is always known,
the receiver may be unknown.
Android Code Camp, Urbino — 2012.

Implicit intent.
Android looks for the best receiver at
runtime. If it finds:

       One, the receiver is activated.

       More than one, the user can choose.

       None, the intent fails.
Android Code Camp, Urbino — 2012.

Implicit intent resolution.
Android decides:
According to the type of component:
    Activity, Service, Broadcast Receiver.

According to the field ACTION.

According to the field CATEGORY.

According to the field DATA (URI e Type).
Android Code Camp, Urbino — 2012.

Broadcast receiver (reprise).
Intra-application / inter-process
communication.

They receive broadcast intents.
May be associated with other components.
Have no GUI.
May make use of notifications.
May start other components.
Android Code Camp, Urbino — 2012.

Broadcast receiver (examples).
Receiving battery status changes.

Being notified of a downloaded file.

Receiving the device boot completed
event.
Android Code Camp, Urbino — 2012.

Applications overview.
Components of an application.

Activity.
Service.
Content provider.
Broadcast receiver.
Intent.
Widget.
Fragment.
Notification.
Android Code Camp, Urbino — 2012.

Widget.
Incorporated in other applications (inside
an ―App Widget Host‖).

Long update interval.
(At least: 30 min.)

Receives inputs from the user and updates
from a Broadcast Receiver (which must be
implemented to act as an app widget).
Android Code Camp, Urbino — 2012.

Widget examples.
Android Code Camp, Urbino — 2012.

Widget examples.
Android Code Camp, Urbino — 2012.

Applications overview.
Components of an application.

Activity.
Service.
Content provider.
Broadcast receiver.
Intent.
Widget.
Fragment.
Notification.
Android Code Camp, Urbino — 2012.

Fragment.
Modular part of an activity.

Has its own lifecycle.

Can be added or removed even while the
activity is in resumed state.

Introduced to address the need of putting
an Activity into another.
Android Code Camp, Urbino — 2012.

Fragments and layout changes.




   Portrait                         Landscape
Android Code Camp, Urbino — 2012.

Applications overview.
Components of an application.

Activity.
Service.
Content provider.
Broadcast receiver.
Intent.
Widget.
Fragment.
Notification.
Android Code Camp, Urbino — 2012.

Notification.
Used to notify the user when an event
happened or has been triggered:
    In the overall system.

       In the activity the user is
       interacting with.

       In a GUI-less component.
       (For instance, a service.)
Android Code Camp, Urbino — 2012.

Toast notification.
Suitable for background events.
No user input allowed.
Barely more visible than Logcat…
Android Code Camp, Urbino — 2012.

Dialog notification.
Suitable for events relating to the current
activity: loading, confirmation, etc.

Allows (or requires) user input.
Android Code Camp, Urbino — 2012.

Status notification.
Suitable for background events.
Requires the user input.
Persistent.
Typically the user has to click on it (or clear
it) to let it disappear from the notifications
bar.
                   When clicked, usually an
                        activity is launched.
Android Code Camp, Urbino — 2012.

Further details…
More on applications.

Layout.
Back stack.
Activity lifecycle.
Service lifecycle.
Fragment lifecycle.
Android Code Camp, Urbino — 2012.

     Layout.
     Typically composed by
     View and ViewGroup (and Fragment).

TableLayout




   EditText

   TextView


    Button
Android Code Camp, Urbino — 2012.

Layout.
Generally defined starting from an xml file.

                                    <RelativeLayout
                                      xmlns:android="http://schemas.android.com/apk/res/android"
                                      xmlns:tools="http://schemas.android.com/tools"
                                      android:layout_width="match_parent"
                                      android:layout_height="match_parent" >

                                      <TextView
                                        android:id="@+id/rss_title"
                                        android:layout_width="wrap_content"
                                        android:layout_height="wrap_content"
                                        … />

                                      <ListView
                                        android:id="@+id/rss_list"
                                        android:layout_width="match_parent"
                                        android:layout_height="wrap_content"
                                        …>
                                      </ListView>

                                      <Button
                                        android:id="@+id/load"
                                        android:layout_width="wrap_content"
                                        … />

                                    </RelativeLayout>
Android Code Camp, Urbino — 2012.

Further details…
More on applications.

Layout.
Back stack.
Activity lifecycle.
Service lifecycle.
Fragment lifecycle.
Android Code Camp, Urbino — 2012.

Back stack.
Each activity belongs to a task.
Each task contains a collection of activities
ordered by their launch event (back stack).
Android Code Camp, Urbino — 2012.

Back stack.
Android handles multiple tasks at the same
time. Only one task can be in foreground
state at
a time.


A new task starts every time an activity has
been lanched from the home screen :
   <action android:name="android.intent.action.MAIN" />
   <category android:name="android.intent.category.LAUNCHER" />

Some launch modes can affect this.
Android Code Camp, Urbino — 2012.

Back stack.
A task structure can be changed by:
• Starting a new activity (increase).
• Using the Back Button (decrease).

The task status changes when:
• There is an interruption for an external event.
• The Home Button is pressed.
• An activity is started from recent menu.
Android Code Camp, Urbino — 2012.

Launch modes.
Generally…
• When an activity starts for the first time it
  is added on top of the current task (or on
  top of a new one if MAIN/LAUNCHER).
• Even if the activity was
  already started,
  another instance will
  be created.
Android Code Camp, Urbino — 2012.

      Launch modes.
      Launch modes allow to define how a new
      instance of an activity is associated with
      the current task. Launch modes can be
      defined via manifest or using intent flags.
Launch Mode                                  Behaviour
   Default       Creates new activity. Different instances can belong to the same
                 task. Each task may contain different instances of same activity.
  SingleTop      Same as Default, but a new instance is started only if the activity
                 is not at the top of the back stack.
 SingleTask      If an old instance of the same activity is present in the system
                 then it will be reactivated, otherwise a new instance is created.
                 There always be one instance of the same activity in the system.
SingleInstance   Same as SingleTask but the activity is always the unique
                 inhabitant of its task.
Android Code Camp, Urbino — 2012.

Launch modes.
DEMO…
Android Code Camp, Urbino — 2012.

Further details…
More on applications.

Layout.
Back stack.
Activity lifecycle.
Service lifecycle.
Fragment lifecycle.
Android Code Camp, Urbino — 2012.

Activity lifecycle.
Android Code Camp, Urbino — 2012.

Activity lifecycle.
Android Code Camp, Urbino — 2012.

Activity lifecycle.
Android Code Camp, Urbino — 2012.

Activity lifecycle.
Android Code Camp, Urbino — 2012.

Activity lifecycle.
Android Code Camp, Urbino — 2012.

Activity lifecycle.
DEMO…
Android Code Camp, Urbino — 2012.

Activity lifecycle.
Saving the activity state.
Android Code Camp, Urbino — 2012.

      Activity lifecycle.
       Even if the system needs to destroy an
       activity in order to get its resources
       back, the state should be preserved in
       order to maintain the user experience
       consistent.
onSaveInstanceState(Bundle)
onRestoreInstanceState(Bundle)
onCreate(Bundle)
Android Code Camp, Urbino — 2012.

More on Activity lifecyle.
When will these methods be called?
   onRestoreInstanceState() just
   after onStart(),
   onSaveInstanceState() before
   onStop() and maybe before
   onPause().

There are no guarantees it will be actually
called (back button)!
Android Code Camp, Urbino — 2012.

More on Activity lifecyle.
What should we save in the Bundle?
    The transient state of the activity.
    The state of the UI (each view saves
    its own status).
What shouldn‘t we save in the Bundle?
    Data non related to that specific
    instance of the activity.
    Persistent data should be saved in
    the onPause() method.
Android Code Camp, Urbino — 2012.

Further details…
More on applications.

Layout.
Back stack.
Activity lifecycle.
Service lifecycle.
Fragment lifecycle.
Android Code Camp, Urbino — 2012.

Started & bound services.
Started:
     Started by another component
     executing the startService()
     method.
     Killed by itself or by another
     component.
Android Code Camp, Urbino — 2012.

Started & bound services.
Bound:
    Started by 1+ components executing
    bindService().
    It lasts until the last bound client has
    called unbindService().
Android Code Camp, Urbino — 2012.

Service lifecycle.
Android Code Camp, Urbino — 2012.

Further details…
More on applications.

Layout.
Back stack.
Activity lifecycle.
Service lifecycle.
Fragment lifecycle.
Android Code Camp, Urbino — 2012.

Fragment lifecycle.
Android Code Camp, Urbino — 2012.

An Android project.
Eclipse Android project structure.

Directories.
Resources management.
Application manifest.
Android Code Camp, Urbino — 2012.

Android folders.
/src: Java sources (or .aidl or…)
/bin: compiled (.apk, ecc…)
/libs: external libraries
/gen: generated sources (R.java)
/assets: unmanaged resources
/res: managed resources
/AndroidManifest.xml: metadata
.properties, .cfg, .xml: others…
Android Code Camp, Urbino — 2012.

An Android project.
Eclipse Android project structure.

Directories.
Resources management.
Application manifest.
Android Code Camp, Urbino — 2012.

Android Asset Packaging Tool.
Each resource inside /res directory has an
integer ID.
The class R.java is generated:
     With a public static final class for
     each type of resources.
     An integer field named as the
     resource it represents.
The R.java is added inside the application
namespace.
Android Code Camp, Urbino — 2012.

Resource resolution.
Each resource can has one or more different
versions. Each version is a different folder with a
proper name.
• layout-long
• anim-v14
• drawable-en-rUS-land-night-notouch
  English language, in America, in landscape
  mode, is night and is not a touch device.
Proper resource is picked at runtime by the
  framework.
Android Code Camp, Urbino — 2012.

Making resources.
Declaration via XML:
   <Button android:id=" @+id/nice_button " />
   <string name=―hello_world‖> hello world</string>




Each file should be created in a specific
/res subdirectory.
Android Code Camp, Urbino — 2012.

Accessing resources.
Via XML:
   @[<package_name>:]<resource_type>/<resource_name>

   <Button android:text=" @string/hello_world " />



Via source code:
   [<package_name>.]R.<resource_type>.<resource_name>

   ImageView imageView = (ImageView)
       findViewById(R.id.myimageview);
   imageView.setImageResource(R.drawable.myimage);
Android Code Camp, Urbino — 2012.

An Android project.
Eclipse Android project structure.

Directories.
Resources management.
Application manifest.
Android Code Camp, Urbino — 2012.

Application manifest.
AndroidManifest.xml in root directory.

Describes the application, its name, its
package, its namespace, its permissions and so
forth.
Declares the minimum and the targeted API
level.

It also describes any components in the
application: activities, services, receivers, etc.
Android Code Camp, Urbino — 2012.

Tutorial.
Fancy ways to say „hello world―.

Preparing the work environment.
Creating a new project.
„Hello World― via Logcat.
Layouts, callbacks and toast notifications.
Intents and navigation.
Lists.
Status notifications.
Implementing a background service.
Android Code Camp, Urbino — 2012.

Preparing the environment.
Installing the Eclipse IDE.
Adding the Android toolchain (ADT):
        https://dl-ssl.google.com/android/eclipse/

Let it download the Android SDK.

…we can start!
Android Code Camp, Urbino — 2012.

Tutorial.
Fancy ways to say „hello world―.

Preparing the work environment.
Creating a new project.
„Hello World― via Logcat.
Layouts, callbacks and toast notifications.
Intents and navigation.
Lists.
Status notifications.
Implementing a background service.
Android Code Camp, Urbino — 2012.

Creating a new project.
Android Code Camp, Urbino — 2012.

Tutorial.
Fancy ways to say „hello world―.

Preparing the work environment.
Creating a new project.
„Hello World― via Logcat.
Layouts, callbacks and toast notifications.
Intents and navigation.
Lists.
Status notifications.
Implementing a background service.
Android Code Camp, Urbino — 2012.

Android log.
Class android.util.Log.

Different levels of logging:
      ASSERT: Log.wtf()
      ERROR: Log.e()
      WARN: Log.w()
      INFO: Log.i()
      DEBUG: Log.d()
      VERBOSE: Log.v()
Android Code Camp, Urbino — 2012.

Android log.
Each log entry has several parameters:
    TAG: discriminator (internal to app).
    Messaggio: content.
    Eccezione: optional.
Android Code Camp, Urbino — 2012.

Tutorial.
Fancy ways to say „hello world―.

Preparing the work environment.
Creating a new project.
„Hello World― via Logcat.
Layouts, callbacks and toast notifications.
Intents and navigation.
Lists.
Status notifications.
Implementing a background service.
Android Code Camp, Urbino — 2012.

Layouts.
Simple and structured way of developing
the graphical interface of an application.

Flexible and dynamic.

For instance:
     LinearLayout,
     RelativeLayout,
     FrameLayout.
Android Code Camp, Urbino — 2012.

LinearLayout.
<LinearLayout
     android:layout_width=„match_parent“
     android:layout_height=„match_parent“
     android:orientation=„horizontal“
     >
     <Item1 />
     <Item2 />
     <Item3 />
</LinearLayout>
Android Code Camp, Urbino — 2012.

RelativeLayout.
<RelativeLayout>
     <Item1 />
     <Item2 layout_below=„Item1“
             layout_alignParentLeft=„true“ />
     <Item3 layout_below=„Item1“
            layout_alignParentRight=„true“ />
</RelativeLayout>
Android Code Camp, Urbino — 2012.

Buttons & callbacks.
<Button android:id=„@+id/buttonToast“ />

Button button = (Button)
     this.findViewById(R.id.buttonToast);

button.setOnClickListener(
     new OnClickListener(){

       @Override
       public void onClick(View arg0) {
       }
});
Android Code Camp, Urbino — 2012.

Toast notifications.
Created via static method:

Toast.makeText(Context,
     “Text”,
     Toast.LENGTH_SHORT).show();


Text is shown in an overlay dialog for a
predefined duration.
Android Code Camp, Urbino — 2012.

Tutorial.
Fancy ways to say „hello world―.

Preparing the work environment.
Creating a new project.
„Hello World― via Logcat.
Layouts, callbacks and toast notifications.
Intents and navigation.
Lists.
Status notifications.
Implementing a background service.
Android Code Camp, Urbino — 2012.

Implicit intent.
Intent i = new Intent(
     Intent.ACTION_VIEW,
     Uri.parse("http://www.google.com"));
Context.startActivity(i);


The default action ACTION_VIEW is defined
by the system.

It will be handled by the system browser
(by default, since it targets an HTTP
resource).
Android Code Camp, Urbino — 2012.

Explicit intent.
Intent i = new Intent(
     Context,
     Class);
Context.startActivity(i);


Intent targeting an explicit class (an
activity, in this case).

Will not be handled nor resolved at runtime
by the system.
Android Code Camp, Urbino — 2012.

Tutorial.
Fancy ways to say „hello world―.

Preparing the work environment.
Creating a new project.
„Hello World― via Logcat.
Layouts, callbacks and toast notifications.
Intents and navigation.
Lists.
Status notifications.
Implementing a background service.
Android Code Camp, Urbino — 2012.

Lists.
Lists of data are displayed by a ListView.

Data is handled by a ListAdapter:
    It handles access to the data.
    Determines how it is shown.

Built in ArrayAdapter works on generic
objects.
Android Code Camp, Urbino — 2012.

Custom list adapters.
In order to customize lists:
     Adapt data shown for each entry,
     Adapt layout,
     Adapt colors, formats, headers, etc.

You need to implement a custom
     ListAdapter, that overrides
     the getView() method.
Android Code Camp, Urbino — 2012.

Tutorial.
Fancy ways to say „hello world―.

Preparing the work environment.
Creating a new project.
„Hello World― via Logcat.
Layouts, callbacks and toast notifications.
Intents and navigation.
Lists.
Status notifications.
Implementing a background service.
Android Code Camp, Urbino — 2012.

Components of a notification.
Icon (top bar and notification panel).
Ticker text (message in top bar).
Overlay number.
Flags (AUTO_CANCEL, INSISTENT, etc).
Content view (panel),
     can be generated (see LatestEvent).
PendingIntent determining action.
Unique Identifier.
Android Code Camp, Urbino — 2012.

Updating notifications.
The panel shows one single notification for
each unique notification identifier.
Ensures there is a single notification for
each kind of notification provided by an
application (logical separation).

PendingIntent instances can be updated
by the application (updates the action, not
the notification), and viceversa.
Android Code Camp, Urbino — 2012.

Tutorial.
Fancy ways to say „hello world―.

Preparing the work environment.
Creating a new project.
„Hello World― via Logcat.
Layouts, callbacks and toast notifications.
Intents and navigation.
Lists.
Status notifications.
Implementing a background service.
Android Code Camp, Urbino — 2012.

Background service.
An Intent is used to explicitly specify a
service to start and to stop.

Intent serviceIntent = new Intent(
     Context, Service.class);

Context.startService(serviceIntent);

Mais conteúdo relacionado

Mais procurados

Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for androidAdrian Mikeliunas
 
Mono for Android Development
Mono for Android DevelopmentMono for Android Development
Mono for Android DevelopmentThinslices
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application DevelopmentRamesh Prasad
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Androidguest213e237
 
Android development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWangAndroid development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWang佐軒 王
 
Kandroid 4th Seminar Design The Life 22 Oct2009
Kandroid 4th Seminar   Design The Life 22 Oct2009Kandroid 4th Seminar   Design The Life 22 Oct2009
Kandroid 4th Seminar Design The Life 22 Oct2009sbroh
 
Milam j brooke project 4 tablet-mobile design
Milam j brooke project 4 tablet-mobile designMilam j brooke project 4 tablet-mobile design
Milam j brooke project 4 tablet-mobile designbmi6802
 
An brief introduction to android operating system
An brief introduction to android operating systemAn brief introduction to android operating system
An brief introduction to android operating systemAlexander Decker
 
Enhancing the User Experience Through the Sense of Touch with Bob Heubel
Enhancing the User Experience Through the Sense of Touch with Bob HeubelEnhancing the User Experience Through the Sense of Touch with Bob Heubel
Enhancing the User Experience Through the Sense of Touch with Bob HeubelFITC
 
Introduction to Android App Development
Introduction to Android App DevelopmentIntroduction to Android App Development
Introduction to Android App DevelopmentAndri Yadi
 
Os eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfOs eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfweerabahu
 
Cygnet mobility solutions & case studies
Cygnet mobility solutions & case studiesCygnet mobility solutions & case studies
Cygnet mobility solutions & case studiesTarak Joshi
 
Android As A Mobile Platform V2
Android As A Mobile Platform V2Android As A Mobile Platform V2
Android As A Mobile Platform V2sbroh
 

Mais procurados (19)

Ii 1300-java essentials for android
Ii 1300-java essentials for androidIi 1300-java essentials for android
Ii 1300-java essentials for android
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating System
 
Anuradha_Resume_2016
Anuradha_Resume_2016Anuradha_Resume_2016
Anuradha_Resume_2016
 
Mono for Android Development
Mono for Android DevelopmentMono for Android Development
Mono for Android Development
 
Android Application Development
Android Application DevelopmentAndroid Application Development
Android Application Development
 
Mobile Application Development With Android
Mobile Application Development With AndroidMobile Application Development With Android
Mobile Application Development With Android
 
Android development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWangAndroid development basic _ZuoSyuanWang
Android development basic _ZuoSyuanWang
 
TRENDS: What You Need To Know From CES 2012
TRENDS: What You Need To Know From CES 2012TRENDS: What You Need To Know From CES 2012
TRENDS: What You Need To Know From CES 2012
 
Kandroid 4th Seminar Design The Life 22 Oct2009
Kandroid 4th Seminar   Design The Life 22 Oct2009Kandroid 4th Seminar   Design The Life 22 Oct2009
Kandroid 4th Seminar Design The Life 22 Oct2009
 
Milam j brooke project 4 tablet-mobile design
Milam j brooke project 4 tablet-mobile designMilam j brooke project 4 tablet-mobile design
Milam j brooke project 4 tablet-mobile design
 
Mobile app
Mobile appMobile app
Mobile app
 
An brief introduction to android operating system
An brief introduction to android operating systemAn brief introduction to android operating system
An brief introduction to android operating system
 
Android Report
Android ReportAndroid Report
Android Report
 
Enhancing the User Experience Through the Sense of Touch with Bob Heubel
Enhancing the User Experience Through the Sense of Touch with Bob HeubelEnhancing the User Experience Through the Sense of Touch with Bob Heubel
Enhancing the User Experience Through the Sense of Touch with Bob Heubel
 
All about android
All about androidAll about android
All about android
 
Introduction to Android App Development
Introduction to Android App DevelopmentIntroduction to Android App Development
Introduction to Android App Development
 
Os eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfOs eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdf
 
Cygnet mobility solutions & case studies
Cygnet mobility solutions & case studiesCygnet mobility solutions & case studies
Cygnet mobility solutions & case studies
 
Android As A Mobile Platform V2
Android As A Mobile Platform V2Android As A Mobile Platform V2
Android As A Mobile Platform V2
 

Semelhante a Android Code Camp 2012 - eng

androidPramming.ppt
androidPramming.pptandroidPramming.ppt
androidPramming.pptBijayKc16
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating systemSalma Begum
 
presentation2-141101015616-conversion-gate01.pdf
presentation2-141101015616-conversion-gate01.pdfpresentation2-141101015616-conversion-gate01.pdf
presentation2-141101015616-conversion-gate01.pdfimau6
 
Introduction to Mobile Development
Introduction to Mobile DevelopmentIntroduction to Mobile Development
Introduction to Mobile DevelopmentPragnesh Vaghela
 
Android_Seminar
Android_SeminarAndroid_Seminar
Android_SeminarKiran Ps
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating SystemBilal Mirza
 
android architecture
android architectureandroid architecture
android architectureAashita Gupta
 
2011 android
2011 android2011 android
2011 androidvpedapolu
 
Android and it’s applications
Android and it’s applicationsAndroid and it’s applications
Android and it’s applicationsamee yaami
 
android technology
android technology android technology
android technology Sai Kumar
 
Android By Manish Seth
Android By Manish SethAndroid By Manish Seth
Android By Manish SethNitin Gupta
 
PRESENTATION ON ANDROID
PRESENTATION ON ANDROIDPRESENTATION ON ANDROID
PRESENTATION ON ANDROIDRajat Kumar
 

Semelhante a Android Code Camp 2012 - eng (20)

androidPramming.ppt
androidPramming.pptandroidPramming.ppt
androidPramming.ppt
 
Presentation on Android operating system
Presentation on Android operating systemPresentation on Android operating system
Presentation on Android operating system
 
presentation2-141101015616-conversion-gate01.pdf
presentation2-141101015616-conversion-gate01.pdfpresentation2-141101015616-conversion-gate01.pdf
presentation2-141101015616-conversion-gate01.pdf
 
Introduction to Mobile Development
Introduction to Mobile DevelopmentIntroduction to Mobile Development
Introduction to Mobile Development
 
Android_Seminar
Android_SeminarAndroid_Seminar
Android_Seminar
 
Andriod vs iphone
Andriod vs iphoneAndriod vs iphone
Andriod vs iphone
 
Android architecture
Android architectureAndroid architecture
Android architecture
 
What is Android
What is Android What is Android
What is Android
 
Android Operating System
Android Operating SystemAndroid Operating System
Android Operating System
 
Android L
Android LAndroid L
Android L
 
android architecture
android architectureandroid architecture
android architecture
 
Android app development
Android app developmentAndroid app development
Android app development
 
Saminar ppt of
Saminar ppt ofSaminar ppt of
Saminar ppt of
 
2011 android
2011 android2011 android
2011 android
 
Android
AndroidAndroid
Android
 
Android and it’s applications
Android and it’s applicationsAndroid and it’s applications
Android and it’s applications
 
android technology
android technology android technology
android technology
 
Android By Manish Seth
Android By Manish SethAndroid By Manish Seth
Android By Manish Seth
 
Android
Android Android
Android
 
PRESENTATION ON ANDROID
PRESENTATION ON ANDROIDPRESENTATION ON ANDROID
PRESENTATION ON ANDROID
 

Último

Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptxiammrhaywood
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxPoojaSen20
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 

Último (20)

Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptxAUDIENCE THEORY -CULTIVATION THEORY -  GERBNER.pptx
AUDIENCE THEORY -CULTIVATION THEORY - GERBNER.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptxCulture Uniformity or Diversity IN SOCIOLOGY.pptx
Culture Uniformity or Diversity IN SOCIOLOGY.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 

Android Code Camp 2012 - eng

  • 1. Android Code Camp, Urbino — 2012. Benvenuti. Android Code Camp
  • 2. Android Code Camp, Urbino — 2012. Theory overview. The smartphone market. The Android project. Android architecture. The ecosystem. Application overview. Structure of an Android project. Hands-on: setting up the development environment. „Hello World.―
  • 3. Android Code Camp, Urbino — 2012. Mobile market. The smartphone market. Numbers and growth. The Android market. Activations. Application marketplace. Fragmentation.
  • 4. Android Code Camp, Urbino — 2012. The smartphone market. 433 milions of units in 2011. 616 milions of units forecast for 2012. • Market growth (contractino of feature phone sales). • Product obsolescence. Tablets: 320 milions of units in 2015.
  • 5. Android Code Camp, Urbino — 2012. The smartphone market. 2011 2.5 3.9 18.3 50.8 12.5 20.4 Android iOS BlackBerry Symbian Windows Phone Others
  • 6. Android Code Camp, Urbino — 2012. The smartphone market. 2012 5.4 3.6 6.8 7.4 26 104.8 Android iOS BlackBerry Symbian Windows Phone Others
  • 7. Android Code Camp, Urbino — 2012. The Android market. Astounding growth (+106% forecast). Mainly Samsung devices: Up to 33% of all devices. 2012: 500 milions of devices activated. 1.3 milions of peak activations per day.
  • 8. Android Code Camp, Urbino — 2012.
  • 9. Android Code Camp, Urbino — 2012. Application market. Android < iOS: More than 400.000 applications, against 500.000 apps for iOS. • Google Play • Amazon AppStore for Android • Other stores: GetJar, AppBrain, etc.
  • 10. Android Code Camp, Urbino — 2012. Application market. Android < iOS: Only ¼ of revenue, on average. Different market segment / users. Almost 70% of applications are free or follow the freemium model (against 50% on iOS). The fragmentation issue.
  • 11. Android Code Camp, Urbino — 2012. Fragmentation.
  • 12. Android Code Camp, Urbino — 2012. Fragmentation.
  • 13. Android Code Camp, Urbino — 2012. Android. Google‘s mobile OS. History. Versions and evolution. The open-source project.
  • 14. Android Code Camp, Urbino — 2012. A short history of Android. 2003: Andy Rubin founds ―Android Inc‖. “...smarter mobile devices that are more aware of its owner's location and preferences.” 2004: Apple starts ―Project Purple‖, a secret project with AT&T. 2005: Google buys out Android Inc and continues the devlopment of the OS.
  • 15. Android Code Camp, Urbino — 2012. A short history of Android. 2007, jan: Apple releases the first iPhone. 2007, nov: Google, HTC, Samsung reveal the Open Handset Alliance & Android. 2008: first Android phone: HTC Dream (G1).
  • 16. Android Code Camp, Urbino — 2012. Android versions. Year Version Codename 2008 1.0 n/a 2009 1.1 Petit Four 1.5 Cupcake 1.6 Donut 2.0 Eclair 2010 2.2 Froyo (Frozen Yogurt) 2.3 Gingerbread 2011 3.0 Honeycomb 4.0 Ice Cream Sandwich 2012 4.1 Jelly Bean ? 4.2 K…?
  • 17. Android Code Camp, Urbino — 2012. Android versions. 1.5 Soft keyboard, clipboard, video… 1.6 Resolution independence 2.0 Maps, Navigation
  • 18. Android Code Camp, Urbino — 2012. Android versions. 3.0 Digital style, tablet optimization 4.0 Halo theme, Project Butter Google Now, Roboto
  • 19. Android Code Camp, Urbino — 2012. Android: openness. October 2010, Steve Jobs: „Google likes to characterize Android as open and iOS as closed. We think this is disingenuous. […] The real difference is integrated versus fragmented.”
  • 20. Android Code Camp, Urbino — 2012. Android: openness.
  • 21. Android Code Camp, Urbino — 2012. Android: open-source project. The code of Android is available under „free― and „open-source― licenses. Linux kernel (Open Handset Alliance): GNU GPL v2, public development. Android system (Google): Network, telephony, Google apps. Apache License v2.0, private.
  • 22. Android Code Camp, Urbino — 2012. Android: open-source project. Production of a „flagship phone― by Google (Nexus), is followed by release of code (and OEM phones). Google Play is available on certification. „Honeycomb incident― (2011). License is incompatible with GPL (FSF).
  • 23. Android Code Camp, Urbino — 2012. The architecture. Operating System architecture Linux Kernel. Native libraries. Android Runtime. Dalvik Virtual Machine. Core Libraries. Application framework. Application layer.
  • 24. Android Code Camp, Urbino — 2012. The architecture.
  • 25. Android Code Camp, Urbino — 2012. Linux Kernel. Kernel 2.6+. Used for process and thread management, low-level memory management, the network stack, security, for the driver model.
  • 26. Android Code Camp, Urbino — 2012. Native libraries. C/C++ libraries executed on top of the Linux kernel and used in many fields of the Android system. They expose a lot of funcionalities to developers through the application framework.
  • 27. Android Code Camp, Urbino — 2012. Android Runtime. It makes an Android device much different from a mobile Linux implementation. Combining the Dalvik Virtual Machine and the Core Libraries makes possible the execution of Android applications.
  • 28. Android Code Camp, Urbino — 2012. Virtual machine. Software implementation of a machine (with a defined Instruction Set Architecture) that executes programs like a physical machine. Virtualization: simulation of an environment where Guest ISA and Host ISA match. Emulation: simulation of an environment where Guest ISA and Host ISA are different.
  • 29. Android Code Camp, Urbino — 2012. Java virtual machine. Virtual machine that executes programs written in byte-code: intermediate rappresentation between machine language and Java source code. JVM is an Oracle (ex Sun) specification. Main implementations: HotSpot – OpenJDK (GPL). HotSpot – OracleJDK.
  • 30. Android Code Camp, Urbino — 2012. Dalvik virtual machine. Virtual machine that executes .dex (Dalvik Executable) files. Java source code compiled in .class files and converted to .dex format. Each Android application runs in a separate process within its Dalvik virtual machine instance. JIT compiler (since version 2.2).
  • 31. Android Code Camp, Urbino — 2012. Dalvik vs. JVM. Dalvik < JVM. But it is a multidimensional problem. • Register-based. • Efficient with multiple VMs. • Minimum memory footprint. • Small startup time.
  • 32. Android Code Camp, Urbino — 2012. Core libraries. Dalvik does not comply with either the J2SE specifications, nor the J2ME. Core libraries provide most of the functionalities available through the Java libraries, as well as Android specific libraries.
  • 33. Android Code Camp, Urbino — 2012. Application framework. Provides key services, encapsulated in Java objects, to the applications of the above level. These services are available for both system applications and for third party applications.
  • 34. Android Code Camp, Urbino — 2012. Application layer. User level applications written in Java language. System app = Third party App
  • 35. Android Code Camp, Urbino — 2012. The ecosystem. Development ecosystem. Android SDK. Eclipse IDE. Application Programming Interfaces.
  • 36. Android Code Camp, Urbino — 2012. SDK: emulator. Software that emulates the function and appearance of a virtual hardware configuration (AVD: Android Virtual Device).
  • 37. Android Code Camp, Urbino — 2012. SDK: emulator. User-friendly interface to configure AVDs.
  • 38. Android Code Camp, Urbino — 2012. SDK: tools. Logcat: collects logs of an Android device. Lint: static analisys to optimize and detect common mistakes. Proguard: reduce binary size, optimize and obscure given code. It makes applications faster and more resilient to reverse engineering.
  • 39. Android Code Camp, Urbino — 2012. SDK: Dalvik Debug Monitor Serve Debugging tool for Android devices: gathers information about processes, threads, heap, logcat and supports event emulation.
  • 40. Android Code Camp, Urbino — 2012. SDK: Android Developer Tools. Plugin for the Eclipse IDE. It simplifies the creation, compilation and maintenance of projects. It integrates development tools. It includes graphical editors and documentation.
  • 41. Android Code Camp, Urbino — 2012. Eclipse. Open-source development environment, multi-platform and multi-language. It is the reference platform for Android. Alternatives: ANT, NetBeans…
  • 42. Android Code Camp, Urbino — 2012. Android APIs.
  • 43. Android Code Camp, Urbino — 2012. Android 1.5, API 3. Playback and audio/video capture. Speech recognition. Widgets. Notifications. WebView.
  • 44. Android Code Camp, Urbino — 2012. Android 1.6, API 4. Gestures. Speech synthetizer. CDMA support. Variable size and density screens support.
  • 45. Android Code Camp, Urbino — 2012. Android 2.1, API 7. Bluetooth 2.1 support. Live Wallpapers.
  • 46. Android Code Camp, Urbino — 2012. Android 2.2, API 8. JIT compiler. SD card installation support. Speech recognition improvement and third party openness. Flash technology support.
  • 47. Android Code Camp, Urbino — 2012. Android 2.3, API 9/10. Native Voip support (SIP). NFC support. Concurrent Garbage Collector. Improved media format support.
  • 48. Android Code Camp, Urbino — 2012. Android 3.0, API 11. Fragments. ActionBar. New drag ‗n drop APIs. 2D hardware acceleration support. New 3D framework renderscript. Improved media format support.
  • 49. Android Code Camp, Urbino — 2012. Android 3.1, API 12. USB peripherals support. Resizable Widgets. Improved media format support.
  • 50. Android Code Camp, Urbino — 2012. Android 4.0.1, API 14. Smartphone and Tablet merge. Linux kernel 3.x. Redesigned UI to enhance coherence and unification. More powerful notifications. Continuous speech recognition support. Social APIs. Low level streaming APIs.
  • 51. Android Code Camp, Urbino — 2012. Android 4.1.3, API 16. Project Butter. Expandable notifications. Improved social APIs. Advanced speech recognition. Enhanced speech synthetizer. Google Now. Flash technology pulled out.
  • 52. Android Code Camp, Urbino — 2012. Applications overview. Components of an application. Activity. Service. Content provider. Broadcast receiver. Intent. Widget. Fragment. Notification.
  • 53. Android Code Camp, Urbino — 2012. Activity. Each activity represents one fullscreen window.
  • 54. Android Code Camp, Urbino — 2012. Activity. Each activity should be used as an atomic action of the user.
  • 55. Android Code Camp, Urbino — 2012. Activity. Some activities could have a returning value.
  • 56. Android Code Camp, Urbino — 2012. Activity. Activities are probably the most fundamental parts of an app! We are going to return on it…
  • 57. Android Code Camp, Urbino — 2012. Applications overview. Components of an application. Activity. Service. Content provider. Broadcast receiver. Intent. Widget. Fragment. Notification.
  • 58. Android Code Camp, Urbino — 2012. Service. A task the app or the system does without directly affecting the UI (a background task). Examples: Gathering data from the system. Updating data of an app. Download new RSS feeds from a server.
  • 59. Android Code Camp, Urbino — 2012. Service. It cannot directly communicate with the user. Though it can exchange data with activities (which may belong to the same app or not) and the system.
  • 60. Android Code Camp, Urbino — 2012. Service. If a particular service should never be killed by the system, it should be declared as a foreground service.
  • 61. Android Code Camp, Urbino — 2012. Applications overview. Components of an application. Activity. Service. Content provider. Broadcast receiver. Intent. Widget. Fragment. Notification.
  • 62. Android Code Camp, Urbino — 2012. Content provider. • It‘s an abstraction of a set of structured data. • Implements the CRUD interface (create, retrieve, update, and delete). • Can be also used to share data among different applications. Android provides many ready-made providers. It is also possible to implement custom providers.
  • 63. Android Code Camp, Urbino — 2012. Content provider. Some examples: • List of contacts. • List of images on the device. • Data from a DB SQLite. • Data from a web service.
  • 64. Android Code Camp, Urbino — 2012. Applications overview. Components of an application. Activity. Service. Content provider. Broadcast receiver. Intent. Widget. Fragment. Notification.
  • 65. Android Code Camp, Urbino — 2012. Broadcast receiver. Components which are employed for intra-application / inter-process communication. They receive so-called broadcast intents…
  • 66. Android Code Camp, Urbino — 2012. Intent. Are the messaging system between various components of the system. Each intent represents a structure which encapsulates data of a message. An intent can be thought as an abstraction of: An operation to execute. An event which has just happened.
  • 67. Android Code Camp, Urbino — 2012. Intent. Possible values: Field Value Component name it.uniurb.codecamp.test Action ACTION_CALL Data URI tel:07224475 Type integer Category CATEGORY_LAUNCHER Extras "tel_number":int Flags FLAG_ACTIVITY_SINGLE_TOP
  • 68. Android Code Camp, Urbino — 2012. Intent. Send an image: Field Value Action SEND Data content://media/external/pic16 Show a spot by Google Maps: Field Value Action VIEW Data geo:latitude,longitude?z=zoom
  • 69. Android Code Camp, Urbino — 2012. Intent. The sender is always known, the receiver may be unknown.
  • 70. Android Code Camp, Urbino — 2012. Implicit intent. Android looks for the best receiver at runtime. If it finds: One, the receiver is activated. More than one, the user can choose. None, the intent fails.
  • 71. Android Code Camp, Urbino — 2012. Implicit intent resolution. Android decides: According to the type of component: Activity, Service, Broadcast Receiver. According to the field ACTION. According to the field CATEGORY. According to the field DATA (URI e Type).
  • 72. Android Code Camp, Urbino — 2012. Broadcast receiver (reprise). Intra-application / inter-process communication. They receive broadcast intents. May be associated with other components. Have no GUI. May make use of notifications. May start other components.
  • 73. Android Code Camp, Urbino — 2012. Broadcast receiver (examples). Receiving battery status changes. Being notified of a downloaded file. Receiving the device boot completed event.
  • 74. Android Code Camp, Urbino — 2012. Applications overview. Components of an application. Activity. Service. Content provider. Broadcast receiver. Intent. Widget. Fragment. Notification.
  • 75. Android Code Camp, Urbino — 2012. Widget. Incorporated in other applications (inside an ―App Widget Host‖). Long update interval. (At least: 30 min.) Receives inputs from the user and updates from a Broadcast Receiver (which must be implemented to act as an app widget).
  • 76. Android Code Camp, Urbino — 2012. Widget examples.
  • 77. Android Code Camp, Urbino — 2012. Widget examples.
  • 78. Android Code Camp, Urbino — 2012. Applications overview. Components of an application. Activity. Service. Content provider. Broadcast receiver. Intent. Widget. Fragment. Notification.
  • 79. Android Code Camp, Urbino — 2012. Fragment. Modular part of an activity. Has its own lifecycle. Can be added or removed even while the activity is in resumed state. Introduced to address the need of putting an Activity into another.
  • 80. Android Code Camp, Urbino — 2012. Fragments and layout changes. Portrait Landscape
  • 81. Android Code Camp, Urbino — 2012. Applications overview. Components of an application. Activity. Service. Content provider. Broadcast receiver. Intent. Widget. Fragment. Notification.
  • 82. Android Code Camp, Urbino — 2012. Notification. Used to notify the user when an event happened or has been triggered: In the overall system. In the activity the user is interacting with. In a GUI-less component. (For instance, a service.)
  • 83. Android Code Camp, Urbino — 2012. Toast notification. Suitable for background events. No user input allowed. Barely more visible than Logcat…
  • 84. Android Code Camp, Urbino — 2012. Dialog notification. Suitable for events relating to the current activity: loading, confirmation, etc. Allows (or requires) user input.
  • 85. Android Code Camp, Urbino — 2012. Status notification. Suitable for background events. Requires the user input. Persistent. Typically the user has to click on it (or clear it) to let it disappear from the notifications bar. When clicked, usually an activity is launched.
  • 86. Android Code Camp, Urbino — 2012. Further details… More on applications. Layout. Back stack. Activity lifecycle. Service lifecycle. Fragment lifecycle.
  • 87. Android Code Camp, Urbino — 2012. Layout. Typically composed by View and ViewGroup (and Fragment). TableLayout EditText TextView Button
  • 88. Android Code Camp, Urbino — 2012. Layout. Generally defined starting from an xml file. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:id="@+id/rss_title" android:layout_width="wrap_content" android:layout_height="wrap_content" … /> <ListView android:id="@+id/rss_list" android:layout_width="match_parent" android:layout_height="wrap_content" …> </ListView> <Button android:id="@+id/load" android:layout_width="wrap_content" … /> </RelativeLayout>
  • 89. Android Code Camp, Urbino — 2012. Further details… More on applications. Layout. Back stack. Activity lifecycle. Service lifecycle. Fragment lifecycle.
  • 90. Android Code Camp, Urbino — 2012. Back stack. Each activity belongs to a task. Each task contains a collection of activities ordered by their launch event (back stack).
  • 91. Android Code Camp, Urbino — 2012. Back stack. Android handles multiple tasks at the same time. Only one task can be in foreground state at a time. A new task starts every time an activity has been lanched from the home screen : <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> Some launch modes can affect this.
  • 92. Android Code Camp, Urbino — 2012. Back stack. A task structure can be changed by: • Starting a new activity (increase). • Using the Back Button (decrease). The task status changes when: • There is an interruption for an external event. • The Home Button is pressed. • An activity is started from recent menu.
  • 93. Android Code Camp, Urbino — 2012. Launch modes. Generally… • When an activity starts for the first time it is added on top of the current task (or on top of a new one if MAIN/LAUNCHER). • Even if the activity was already started, another instance will be created.
  • 94. Android Code Camp, Urbino — 2012. Launch modes. Launch modes allow to define how a new instance of an activity is associated with the current task. Launch modes can be defined via manifest or using intent flags. Launch Mode Behaviour Default Creates new activity. Different instances can belong to the same task. Each task may contain different instances of same activity. SingleTop Same as Default, but a new instance is started only if the activity is not at the top of the back stack. SingleTask If an old instance of the same activity is present in the system then it will be reactivated, otherwise a new instance is created. There always be one instance of the same activity in the system. SingleInstance Same as SingleTask but the activity is always the unique inhabitant of its task.
  • 95. Android Code Camp, Urbino — 2012. Launch modes. DEMO…
  • 96. Android Code Camp, Urbino — 2012. Further details… More on applications. Layout. Back stack. Activity lifecycle. Service lifecycle. Fragment lifecycle.
  • 97. Android Code Camp, Urbino — 2012. Activity lifecycle.
  • 98. Android Code Camp, Urbino — 2012. Activity lifecycle.
  • 99. Android Code Camp, Urbino — 2012. Activity lifecycle.
  • 100. Android Code Camp, Urbino — 2012. Activity lifecycle.
  • 101. Android Code Camp, Urbino — 2012. Activity lifecycle.
  • 102. Android Code Camp, Urbino — 2012. Activity lifecycle. DEMO…
  • 103. Android Code Camp, Urbino — 2012. Activity lifecycle. Saving the activity state.
  • 104. Android Code Camp, Urbino — 2012. Activity lifecycle. Even if the system needs to destroy an activity in order to get its resources back, the state should be preserved in order to maintain the user experience consistent. onSaveInstanceState(Bundle) onRestoreInstanceState(Bundle) onCreate(Bundle)
  • 105. Android Code Camp, Urbino — 2012. More on Activity lifecyle. When will these methods be called? onRestoreInstanceState() just after onStart(), onSaveInstanceState() before onStop() and maybe before onPause(). There are no guarantees it will be actually called (back button)!
  • 106. Android Code Camp, Urbino — 2012. More on Activity lifecyle. What should we save in the Bundle? The transient state of the activity. The state of the UI (each view saves its own status). What shouldn‘t we save in the Bundle? Data non related to that specific instance of the activity. Persistent data should be saved in the onPause() method.
  • 107. Android Code Camp, Urbino — 2012. Further details… More on applications. Layout. Back stack. Activity lifecycle. Service lifecycle. Fragment lifecycle.
  • 108. Android Code Camp, Urbino — 2012. Started & bound services. Started: Started by another component executing the startService() method. Killed by itself or by another component.
  • 109. Android Code Camp, Urbino — 2012. Started & bound services. Bound: Started by 1+ components executing bindService(). It lasts until the last bound client has called unbindService().
  • 110. Android Code Camp, Urbino — 2012. Service lifecycle.
  • 111. Android Code Camp, Urbino — 2012. Further details… More on applications. Layout. Back stack. Activity lifecycle. Service lifecycle. Fragment lifecycle.
  • 112. Android Code Camp, Urbino — 2012. Fragment lifecycle.
  • 113. Android Code Camp, Urbino — 2012. An Android project. Eclipse Android project structure. Directories. Resources management. Application manifest.
  • 114. Android Code Camp, Urbino — 2012. Android folders. /src: Java sources (or .aidl or…) /bin: compiled (.apk, ecc…) /libs: external libraries /gen: generated sources (R.java) /assets: unmanaged resources /res: managed resources /AndroidManifest.xml: metadata .properties, .cfg, .xml: others…
  • 115. Android Code Camp, Urbino — 2012. An Android project. Eclipse Android project structure. Directories. Resources management. Application manifest.
  • 116. Android Code Camp, Urbino — 2012. Android Asset Packaging Tool. Each resource inside /res directory has an integer ID. The class R.java is generated: With a public static final class for each type of resources. An integer field named as the resource it represents. The R.java is added inside the application namespace.
  • 117. Android Code Camp, Urbino — 2012. Resource resolution. Each resource can has one or more different versions. Each version is a different folder with a proper name. • layout-long • anim-v14 • drawable-en-rUS-land-night-notouch English language, in America, in landscape mode, is night and is not a touch device. Proper resource is picked at runtime by the framework.
  • 118. Android Code Camp, Urbino — 2012. Making resources. Declaration via XML: <Button android:id=" @+id/nice_button " /> <string name=―hello_world‖> hello world</string> Each file should be created in a specific /res subdirectory.
  • 119. Android Code Camp, Urbino — 2012. Accessing resources. Via XML: @[<package_name>:]<resource_type>/<resource_name> <Button android:text=" @string/hello_world " /> Via source code: [<package_name>.]R.<resource_type>.<resource_name> ImageView imageView = (ImageView) findViewById(R.id.myimageview); imageView.setImageResource(R.drawable.myimage);
  • 120. Android Code Camp, Urbino — 2012. An Android project. Eclipse Android project structure. Directories. Resources management. Application manifest.
  • 121. Android Code Camp, Urbino — 2012. Application manifest. AndroidManifest.xml in root directory. Describes the application, its name, its package, its namespace, its permissions and so forth. Declares the minimum and the targeted API level. It also describes any components in the application: activities, services, receivers, etc.
  • 122. Android Code Camp, Urbino — 2012. Tutorial. Fancy ways to say „hello world―. Preparing the work environment. Creating a new project. „Hello World― via Logcat. Layouts, callbacks and toast notifications. Intents and navigation. Lists. Status notifications. Implementing a background service.
  • 123. Android Code Camp, Urbino — 2012. Preparing the environment. Installing the Eclipse IDE. Adding the Android toolchain (ADT): https://dl-ssl.google.com/android/eclipse/ Let it download the Android SDK. …we can start!
  • 124. Android Code Camp, Urbino — 2012. Tutorial. Fancy ways to say „hello world―. Preparing the work environment. Creating a new project. „Hello World― via Logcat. Layouts, callbacks and toast notifications. Intents and navigation. Lists. Status notifications. Implementing a background service.
  • 125. Android Code Camp, Urbino — 2012. Creating a new project.
  • 126. Android Code Camp, Urbino — 2012. Tutorial. Fancy ways to say „hello world―. Preparing the work environment. Creating a new project. „Hello World― via Logcat. Layouts, callbacks and toast notifications. Intents and navigation. Lists. Status notifications. Implementing a background service.
  • 127. Android Code Camp, Urbino — 2012. Android log. Class android.util.Log. Different levels of logging: ASSERT: Log.wtf() ERROR: Log.e() WARN: Log.w() INFO: Log.i() DEBUG: Log.d() VERBOSE: Log.v()
  • 128. Android Code Camp, Urbino — 2012. Android log. Each log entry has several parameters: TAG: discriminator (internal to app). Messaggio: content. Eccezione: optional.
  • 129. Android Code Camp, Urbino — 2012. Tutorial. Fancy ways to say „hello world―. Preparing the work environment. Creating a new project. „Hello World― via Logcat. Layouts, callbacks and toast notifications. Intents and navigation. Lists. Status notifications. Implementing a background service.
  • 130. Android Code Camp, Urbino — 2012. Layouts. Simple and structured way of developing the graphical interface of an application. Flexible and dynamic. For instance: LinearLayout, RelativeLayout, FrameLayout.
  • 131. Android Code Camp, Urbino — 2012. LinearLayout. <LinearLayout android:layout_width=„match_parent“ android:layout_height=„match_parent“ android:orientation=„horizontal“ > <Item1 /> <Item2 /> <Item3 /> </LinearLayout>
  • 132. Android Code Camp, Urbino — 2012. RelativeLayout. <RelativeLayout> <Item1 /> <Item2 layout_below=„Item1“ layout_alignParentLeft=„true“ /> <Item3 layout_below=„Item1“ layout_alignParentRight=„true“ /> </RelativeLayout>
  • 133. Android Code Camp, Urbino — 2012. Buttons & callbacks. <Button android:id=„@+id/buttonToast“ /> Button button = (Button) this.findViewById(R.id.buttonToast); button.setOnClickListener( new OnClickListener(){ @Override public void onClick(View arg0) { } });
  • 134. Android Code Camp, Urbino — 2012. Toast notifications. Created via static method: Toast.makeText(Context, “Text”, Toast.LENGTH_SHORT).show(); Text is shown in an overlay dialog for a predefined duration.
  • 135. Android Code Camp, Urbino — 2012. Tutorial. Fancy ways to say „hello world―. Preparing the work environment. Creating a new project. „Hello World― via Logcat. Layouts, callbacks and toast notifications. Intents and navigation. Lists. Status notifications. Implementing a background service.
  • 136. Android Code Camp, Urbino — 2012. Implicit intent. Intent i = new Intent( Intent.ACTION_VIEW, Uri.parse("http://www.google.com")); Context.startActivity(i); The default action ACTION_VIEW is defined by the system. It will be handled by the system browser (by default, since it targets an HTTP resource).
  • 137. Android Code Camp, Urbino — 2012. Explicit intent. Intent i = new Intent( Context, Class); Context.startActivity(i); Intent targeting an explicit class (an activity, in this case). Will not be handled nor resolved at runtime by the system.
  • 138. Android Code Camp, Urbino — 2012. Tutorial. Fancy ways to say „hello world―. Preparing the work environment. Creating a new project. „Hello World― via Logcat. Layouts, callbacks and toast notifications. Intents and navigation. Lists. Status notifications. Implementing a background service.
  • 139. Android Code Camp, Urbino — 2012. Lists. Lists of data are displayed by a ListView. Data is handled by a ListAdapter: It handles access to the data. Determines how it is shown. Built in ArrayAdapter works on generic objects.
  • 140. Android Code Camp, Urbino — 2012. Custom list adapters. In order to customize lists: Adapt data shown for each entry, Adapt layout, Adapt colors, formats, headers, etc. You need to implement a custom ListAdapter, that overrides the getView() method.
  • 141. Android Code Camp, Urbino — 2012. Tutorial. Fancy ways to say „hello world―. Preparing the work environment. Creating a new project. „Hello World― via Logcat. Layouts, callbacks and toast notifications. Intents and navigation. Lists. Status notifications. Implementing a background service.
  • 142. Android Code Camp, Urbino — 2012. Components of a notification. Icon (top bar and notification panel). Ticker text (message in top bar). Overlay number. Flags (AUTO_CANCEL, INSISTENT, etc). Content view (panel), can be generated (see LatestEvent). PendingIntent determining action. Unique Identifier.
  • 143. Android Code Camp, Urbino — 2012. Updating notifications. The panel shows one single notification for each unique notification identifier. Ensures there is a single notification for each kind of notification provided by an application (logical separation). PendingIntent instances can be updated by the application (updates the action, not the notification), and viceversa.
  • 144. Android Code Camp, Urbino — 2012. Tutorial. Fancy ways to say „hello world―. Preparing the work environment. Creating a new project. „Hello World― via Logcat. Layouts, callbacks and toast notifications. Intents and navigation. Lists. Status notifications. Implementing a background service.
  • 145. Android Code Camp, Urbino — 2012. Background service. An Intent is used to explicitly specify a service to start and to stop. Intent serviceIntent = new Intent( Context, Service.class); Context.startService(serviceIntent);

Notas do Editor

  1. Dati: http://www.idc.com/getdoc.jsp?containerId=prUS23638712