Doodlz App Android How to Program ©1992-2013 by Pearson Education, Inc. All Rights Reserved.

Slides:



Advertisements
Similar presentations
CE881: Mobile and Social Application Programming Simon M. Lucas Menus and Dialogs.
Advertisements

Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
Hello world Follow steps under the sections “Create an AVD” and “Create a New Android Project” at
Filip Debelić What is it? Android is a mobile operating system (OS) based on the Linux kernel and currently developed by Google Android,
Working with Vector Graphics – Lesson 21 Working with Vector Graphics Lesson 2.
Android: Hello World Frank Xu Gannon University. Steps Configuration ▫Android SDK ▫Android Development Tools (ADT)  Eclipse plug-in ▫Android SDK and.
V0.01 © 2009 Research In Motion Limited Introduction to Java Application Development for the BlackBerry Smartphone Trainer name Date.
By: Jeremy Smith.  Introduction  Droid Draw  Add XML file  Layouts  LinearLayout  RelativeLayout  Objects  Notifications  Toast  Status Bar.
Android Programming Beomjoo Seo Sep., 12 CS5248 Fall 2012.
Android Development (Basics)
Route Tracker App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Introducing the Sudoku Example
Copyright ©: SAMSUNG & Samsung Hope for Youth. All rights reserved Tutorials Software: Building apps Suitable for: Advanced.
CS5103 Software Engineering Lecture 08 Android Development II.
© Keren Kalif Intro to Android Development Written by Keren Kalif, Edited by Liron Blecher Contains slides from Google I/O presentation.
Interactive Input Methods & Graphical User Input
6-2 2D Graphics CSNB544 Mobile Application Development Thanks to Utexas Austin.
Sensing. Possible sensors on devices – Documented in SensorEvent class Accelerometer (m/s 2 ) – acceleration in x, y, z axes Magnetic Field (micro Tesla)
Favorite Twitter® Searches App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Android How to Program Presented by Thomas Bucag, Rob Goodfellowe, Samantha Tomeï © by Pearson Education, Inc. All Rights Reserved.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
CGMB214: Introduction to Computer Graphics
Basic Android Tutorial USF’s Association for Computing Machinery.
DUE Hello World on the Android Platform.
© CCI Learning Solutions Inc. 1 Lesson 5: Basic Troubleshooting Techniques Computer performance Care of the computer Working with hardware Basic maintenance.
INTRODUCTION TO ANDROID. Slide 2 Application Components An Android application is made of up one or more of the following components Activities We will.
SpotOn Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Android Boot Camp for Developers Using Java, 3E
Section 8.1 Create a custom theme Design a color scheme Use shared borders Section 8.2 Identify types of graphics Identify and compare graphic formats.
Sensors – Part I SE 395/595.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 3 Welcome Application Introduction to Visual Programming.
CS378 - Mobile Computing Sensing and Sensors Part 2.
Field Trip #19 Animations with Java By Keith Lynn.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Introduction to Android (Part.
Chapter 13: AutoCAD DesignCenter. After completing this Chapter, you will be able to use the following: Overview of DesignCenter Container, Content Type.
Announcements Homework #2 will be posted after class due Thursday Feb 7, 1:30pm you may work with one other person No office hours tonight (sorry!) I will.
Topics Introduction Scene Graphs
Splatter! ALPHA Presentation By: David Kikuta March 29, 2011.
Styles, Dialog Boxes, and Menus. Styles Allow creation of a common format – placed in res/values/styles.xml – file name is incidental Can be applied.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Sensors in android. App being more applicable Keeping track of your heart beat while jogging. Pointing the phone camera towards the night sky to know.
MOBILE COMPUTING D10K-7D02 MC05: Android UI Design Dr. Setiawan Hadi, M.Sc.CS. Program Studi S-1 Teknik Informatika FMIPA Universitas Padjadjaran.
© 2016 Cengage Learning®. May not be scanned, copied or duplicated, or posted to a publicly accessible website, in whole or in part. Android Boot Camp.
CS378 - Mobile Computing More UI - Part 2. Special Menus Two special application menus – options menu – context menu Options menu replaced by action bar.
CS378 - Mobile Computing Sensing and Sensors Part 2.
Jozef Goetz © Copyright by Pearson Education, Inc. All Rights Reserved 1 Credits: Copyright  Pearson Education, Inc. All rights.
Lecture 4: Sensors Topics: Motion, Position, and Environmental Sensors Date: Feb 11, 2016.
Flag Quiz Game App Android How to Program © by Pearson Education, Inc. All Rights Reserved.
Basic 2D Graphics in Android. Android Graphics Programming There are many ways to do graphics programming in Android – 2D vs. 3D – static vs. dynamic.
CPE 490/590 – Smartphone Development
Android Fundamentals. What is Android Software stack for mobile devices Software stack for mobile devices SDK provides tools and APIs to develop apps.
The Flag Quiz app tests your ability to correctly identify 10 flags from various countries and territories.
CHAPTER 8 Sensors and Camera. Chapter objectives: Understand Motion Sensors, Environmental Sensors and Positional Sensors Learn how to acquire measurement.
The Doodlz app enables you to paint by dragging one or more fingers across the screen. The app provides options for setting the drawing color.
Editing a Twitter search. Viewing search results in a browser.
Whittier STEM Fair 2016 CARLI PECORARO’S ANDROID APP PROJECT.
Section 8.1 Section 8.2 Create a custom theme Design a color scheme
Vijay Kumar Kolagani Dr. Yingcai Xiao
Android Application 2D Graphics cs.
Android Layouts 24 July 2018 S.RENUKADEVI/AP/SCD/ANDROID LAYOUTS 1.
Creation of an Android App By Keith Lynn
Mobile Application Development Chapter 4 [Android Navigation and Interface Design] IT448-Fall 2017 IT448- Fall2017.
Vijay Kumar Kolagani Dr. Yingcai Xiao
Interactive Input Methods & Graphical User Input
Cannon Game App Android How to Program
Interactive Input Methods & Graphical User Input
Android Programming Tutorial
CA16R405 - Mobile Application Development (Theory)
Presentation transcript:

Doodlz App Android How to Program © by Pearson Education, Inc. All Rights Reserved.

Test Drive the Doodlz app © by Pearson Education, Inc. All Rights Reserved.

© by Pearson Education, Inc. All Rights Reserved.

Technologies Overview No Android 3.0+ features in this app, but we specify in the manifest that we target 3.0SDK, so we get 3.0’s look-and-feel ▫Holographic theme Use SensorManager to Listen for Accelerometer Events ▫Detects movement of device ▫User will shake device to erase drawing ▫Other sensors: gravity, gyroscope, light, linear acceleration, magnetic field, pressure, proximity, rotation vector and temperature ▫To listen for sensor events, you et a reference to system’s SensorManager service ▫Classes and interfaces for processing sensor events are in package android.hardware © by Pearson Education, Inc. All Rights Reserved.

Technologies Overview Create Custom Dialogs ▫AlertDialogs display only simple Strings and Buttons ▫Class Dialog displays custom GUIs (eg SeekBars) AtomicBoolean ▫Sensor events are handled in separate thread of excution from GUI events  so possible shake event handler could try to display confirmation dialog, when another dialog is on screen ▫AtomicBoolean manages a Boolean in a thread- safe manner, so it can be accessed by multiple threads © by Pearson Education, Inc. All Rights Reserved.

Technologies Overview Custom Colors ▫Specify alpha, red, green, blue components of colors using SeekBars in a Dialog ▫Class Color provides methods for assembling a color and for obtaining components values from a Color Drawing Lines and Paths ▫Drawing on a bitmap here ▫Associating a canvas with a bitmap, use Canvas to draw on the Bitmap (which can be displayed and saved) © by Pearson Education, Inc. All Rights Reserved.

Technologies Overview Processing Touch events ▫Touch, Drag, or Lift with one or more fingers ▫Information for each finger stored in Path object  Consists of line segments ▫Using View method onTouchEvent which receives a MotionEvent  Need type of touch event and ID of finger Saving Drawing to device’s Gallery ▫ContentResolver enables app to read and store data ▫Uses OutputStream © by Pearson Education, Inc. All Rights Reserved.

Technologies Overview Using Toasts to display a message for a short time ▫Used to display minor error messages or informational messages briefly ▫Used in this app to let user know image was successfully saved to the gallery © by Pearson Education, Inc. All Rights Reserved.

Building the App’s GUI and Resource Files Ensure Build Target is Android Min SDK Version: 8 In AndroidManifest.xml, set android:targetSdkVersion attribute to “11”, which represents Android 3.0 SDK ▫So will run on 2.3.3, but if device is a Tablet, it will have the holographic theme seen on tablets Delete and replace main.xml ▫Only component is custom View class, DoodleView © by Pearson Education, Inc. All Rights Reserved.

Added manually to main.xml

© by Pearson Education, Inc. All Rights Reserved. Maximum value of SeekBar is 255

© by Pearson Education, Inc. All Rights Reserved.

LinearLayout has white background and contains a View to display the current drawing color. The white enables the color to display accurately when the user makes the color semitransparent with alphaSeekBar.

© by Pearson Education, Inc. All Rights Reserved.

Displays sample line in current width and current color.

Building the App Two classes Doodlz (the Activity subclass) ▫Provides the app’s menu, dialogs and accelerometer event handling DoodleView (View subclass) ▫Processes user’s touches and draws the corresponding lines © by Pearson Education, Inc. All Rights Reserved.

App’s Java program structure © by Pearson Education, Inc. All Rights Reserved. onCreate +enableAccer onPause +disableAccer registerListener onSensorChanged +clear Builder positive Button onClick onCreateOptionsMenu onOptionsItemSelected showColorDialogshowLineWidthDialog +setDrawingColor +saveImage+getDrawingColor colorSeekBar. onProgressChanged setColorButtonListener onClick +getLineWidth+setLineWidth

App’s Java program structure © by Pearson Education, Inc. All Rights Reserved. onCreate onOptionsItemSelected showLineWidthDialog +clear +setDrawingColor +saveImage+getDrawingColor +getLineWidth+setLineWidth widthSeekBar. onProgressChanged setLineWidthListener onClick

DoodleView – subclass of View © by Pearson Education, Inc. All Rights Reserved. +clear +setDrawingColor +saveImage +getDrawingColor +getLineWidth +setLineWidth DoodleViewonSizeChangedonDrawonTouchEvent +touchStarted +touchEnded +touchMoved

© by Pearson Education, Inc. All Rights Reserved.

Note: Do NOT need redColorSeekBarChanged and blueColorSeekBarChanged, etc.

© by Pearson Education, Inc. All Rights Reserved.

Paint is like a “paint brush” - it has a color, style, size, etc.

© by Pearson Education, Inc. All Rights Reserved. DoodleView’s size not determined until it’s inflated and added to Doodlz activity’s View hiearchy; therefore cannot determine size of drawing Bitmap in onCreate.

© by Pearson Education, Inc. All Rights Reserved.

System automatically determines when the View’s onDraw method should be called.

© by Pearson Education, Inc. All Rights Reserved. Not index of the finger, but the index at which finger’s information is located in this MotionEvent object. Index of finger New finger: first finger New finger: others Removed finger

© by Pearson Education, Inc. All Rights Reserved. Draw lines

© by Pearson Education, Inc. All Rights Reserved.

Contains touch info for multiple moves on screen if they occur at same time

© by Pearson Education, Inc. All Rights Reserved. Some devices sensitive enough to generate MotionEvent even if user attempts to hold finger motionless Adding geometric quadratic Bezier curve

© by Pearson Education, Inc. All Rights Reserved.

Saving Image Possible image won’t appear in Gallery until device scans for new media In AVD’s development tools, touch MediaScanner option, then the new image will appear in the Gallery © by Pearson Education, Inc. All Rights Reserved.

Wrap up Enabled a pre-Android 3.0 device to use Android 3.0’s holographic user interface components Processed sensor events (accelerator) by register SensorEventListener with SensorManager service Displayed custom dialogs with complex GUIs Used thread-safe AtomicBoolean to prevent multiple dialogs from displaying Created custom colors Drew onto Bitmaps using Canvas objects Saved Bitmap as an image to Gallery © by Pearson Education, Inc. All Rights Reserved.

Wrap up Stored information on each finger drag in a Path object Overrode onTouchEvent and used the MotionEvent parameter to get type of touch event and ID of finger that generated it Got an OutputStream from a ContentResolver Used a Toast to display a brief message – be able to write code to do this on Quiz © by Pearson Education, Inc. All Rights Reserved.