Mobile Development Workshop ANDROID REFRESHER Overview The - - PowerPoint PPT Presentation

mobile development workshop
SMART_READER_LITE
LIVE PREVIEW

Mobile Development Workshop ANDROID REFRESHER Overview The - - PowerPoint PPT Presentation

Mobile Development Workshop ANDROID REFRESHER Overview The Android operating system Views, Layouts and Activities Event listeners Using Intents to request actions First up Start a new project in Android Studio Call it Before and After


slide-1
SLIDE 1

Mobile Development Workshop

ANDROID REFRESHER

slide-2
SLIDE 2

Overview

The Android operating system Views, Layouts and Activities Event listeners Using Intents to request actions

slide-3
SLIDE 3

First up…

Start a new project in Android Studio Call it Before and After

slide-4
SLIDE 4

What is Android?

Android is a mobile operating system developed by Google Is it based on the Linux kernel Is uses Java as a main development language

slide-5
SLIDE 5

How do you create Android applications?

You write applications for Android using the SDK which is built in Java

  • Writing Android applications require knowledge of Java and an understanding of Object Oriented

Development principles

  • There is also an NDK that allows you to write applications in C
  • Many parties are constantly exploring extending Android’s available development languages

Java’s SDK is essentially a framework that packages the main facets of an Android application You write apps by tying together and extending various components of the framework

slide-6
SLIDE 6

Views

The basic building blocks of a User Interface Responsible for drawingthe interface and responding to events

slide-7
SLIDE 7

Some common views

slide-8
SLIDE 8

Layouts

Special types of views that hold other views Invisible Each layout type have different rules and properties for positioning their child views Layouts form the visible aspect of activities

slide-9
SLIDE 9

Popular layouts

Linear Layout

  • Orders its child view sequentially either horizontally or vertically

Relative Layout

  • Arranges its children in relation to itself as well as other children

WebView

  • Displays HTML content (the stuff websites are made of)

FrameLayout

  • Arranges its children along the Z-axis (stacks views on top of each other)
slide-10
SLIDE 10

Back to your program…

Change the layout of your main activity to use a LinearLayout with vertical orientation Add a button as the LinearLayout’s first child Add a FrameLayout as the LinearLayout’s second child Add a SeekBar (slider) as the LinearLayout’sthird child Add two ImageViews as children of the FrameLayout

slide-11
SLIDE 11

Activities

An Android application is a collection of components An Activity is one of the main components of Android

  • contains application logic (code)

Applications generally consist of one or more activities

  • One activity is delegated as the Main activity
  • The main activity is started automatically when the application is started
slide-12
SLIDE 12

Events

Events are triggered when a user interacts with a view Event listeners are used to specify what should happen when a particular event takes place Many standard event listeners are found inside the View class

slide-13
SLIDE 13

Event listener callbacks

Android provides many View.On*Listener classes with appropriate callback methods

  • nClick
  • Called when the user touches the view
  • nLongClick
  • Called when the user touches and holds the view
  • nFocusChange
  • Called when a user navigate to, or away from a view
slide-14
SLIDE 14

Back to your program…

Bind the views inside your layout to variables inside your activity Add an OnClickListner object to your button

  • When the button is clicked call an intent to have the camera take a picture
  • When thee image is returned, set it as the image resource of the first ImageView inside your frame

layout

slide-15
SLIDE 15

Into to intents

A messaging object used to request that action be taken Generally used to

Start components such as activities Send information from one component to another

slide-16
SLIDE 16

Intents in action

slide-17
SLIDE 17

To create an Intent

Two types

  • Explicit
  • Provide context
  • Specify a recipient
  • Implicit
  • Specify an action
slide-18
SLIDE 18

Back to your program…

Extend the initial functionality of the button click We’re going to request a picture be taken two times Assign each returned picture to respective ImageView

slide-19
SLIDE 19

Finally…

Add a OnChange listener to your slider Use the progress of the slider to set the alpha of the ImageView on top in your frame layout