pooh.poly.asu.edu
Download
Report
Transcript pooh.poly.asu.edu
July 17, 2015
CST594 – Mobile Computing
Team members:
Joanne Kuei-Chen Ho
Ray Hedgecock
Shubha Sundaramurthy
Krishna Tanmaya Nelapatla
Agastheswar Suribhatla
Yih-Kuang Lu
Hieu Nguyen
1
Overview
2
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Android tutorial
Introduction
Platform
IDE Setup
Application Development walkthrough
Tower of Hanoi (Android game demo)
Introduction
Application walkthrough and demo
KnockKnock Client (client/server demo)
Introduction
Application walkthrough and demo
Location App (location services)
Introduction
Application walkthrough and demo
Quiz
Introduction
Brief
3
July 17, 2015
CST594 – Mobile Computing
Android Presentation
History
Aug 2005 Google purchased Android, Inc.
Nov 2007 Android was unveiled along with the
founding of OHA (Open Handset Alliance).
Android is open source – code are released under
Apache License by Google.
Oct 2008 1st Android-powered phone was released.
Google Play – primary app store. Oct 2012, approx.
700K apps available w/ ~25B downloads.
Had a 75% share of global smartphone market by 3rd
quarter of 2012 with 500M devices activated. Jul 2012
- 52% of US smartphone share; 90% in China).
Latest stable release – 4.2.1 Jelly Bean, 11/2012.
Introduction (cont.)
July 2012 Jelly
Bean (SDK 4.1.x,
4.2, API 16, 17)
4
July 17, 2015
CST594 – Mobile Computing
Android Presentation
April 2009
Cupcake (SDK
1.5, API 3)
Sept. 2009 Donut
(SDK 1.6, API 4)
Dec. 2011 Ice
Cream Sandwich
(SDK 4.0.x, API 15)
May 2011
Honeycomb (SDK
3.1,3.2, API 12. 13)
Oct. 2009
Éclair (SDK
2.0-2.1, API 7)
May 2010 Froyo
(SDK 2.2, API 8)
Dec. 2010
Gingerbread (SDK
2.3-2.3.7, API 9, 10)
Introduction (cont.)
ANDROID VERSION
1.0 (G1)
1.5 (Cupcake)
1.6 (Donut)
SDK RELEASE*
5
July 17, 2015
CST594 – Mobile Computing
Android Presentation
NOTABLE UPDATES
February 2008
•GPS and Bluetooth (but not stereo Bluetooth)
•Multitasking
•Tight integration with Google services like Gmail, Google
Maps (with Street View), and Google Calendar
•Apps: Amazon MP3 Store; YouTube
•Android Market (about 35 apps at launch)
•No Microsoft Exchange Server; no camcorder
April 2009
•Universal search box (search had been limited to the Web)
•Revamped Android Market: Browsing categories (Apps,
Games, Downloads) and filters (Top Free, Top Paid, Just In)
•Camera: Toggle between camera and video modes;
integrated photo gallery and camera with bulk photo deleting
•SDK expands support for gestures, voice-to-text
September 2009
•Virtual onscreen keyboard
•Camcorder mode for recording (and watching) video
•Stereo Bluetooth
•Home screen widgets and folders
•Copy/paste and search within the browser
•Direct upload to YouTube and Picasa
Introduction (cont.)
ANDROID VERSION
2.0 (Eclair)
2.1 (Eclair, second
helping)
2.2 (Froyo)
2.3 (Gingerbread)
SDK RELEASE*
6
July 17, 2015
CST594 – Mobile Computing
Android Presentation
NOTABLE UPDATES
October 2009
•Multiple user accounts
•Exchange support; universal e-mail inbox
•Quick Contact pop-up widget to launch communications with
friends in the address book
•Search saved SMS and MMS messages
•Camera improvements include support for flash and digital
zoom
•Bluetooth 2.1
•Keyboard improvements: Adaptive dictionary that includes
contact names in suggestions
January 2010
•Live wallpaper; five home screens
•Speech-to-text added to any text field; microphone icon for voice
dictation in e-mails, texts, and so on
May 2010
•Speedier OS
•USB tethering and hot-spot support
•Android Market update: Batch and automatic updates; installing
apps to the SD card
•Adobe Flash 10.1
•File uploading in the browser
•Improved Microsoft Exchange support: Security policies, global
address lookup, calendar sync, remote wipe
•Bluetooth support for voice dialing and contact sharing
December 2010
•Redesigned copy/paste
•WebM video compression support
•NFC (near-field communication) support
•Switch to front-facing camera from camera app
•Virtual keyboard shortcuts
Introduction (cont.)
ANDROID VERSION
3.0 (Honeycomb)
3.1-3.2.6 (Honeycomb)
4.0 (Ice Cream
Sandwich)
SDK RELEASE*
7
July 17, 2015
CST594 – Mobile Computing
Android Presentation
NOTABLE UPDATES
February 2011
•3D graphics support
•Side-by-side browser tabs; private browsing
•Dual-pane modes for address book, e-mail
•Redesigned UI includes program thumbnails
•Video chatting with Google Talk
•Full-screen-mode photo gallery
•Bluetooth tethering
May 2011February 2012
•Support for peripherals like keyboards and game pads
•Resizable widgets
•"Pay as you go" support for 3G, 4G tablets
•Various bug fixes and enhancements
October 2011
•Support for virtual buttons in addition to touch-sensitive buttons
•Create folders by dragging apps on top of each other
•A new app tray tab for thumbing through widgets
•Calendar app now supports pinch-to-zoom
•Gmail gets offline search, swiping between conversations
•Revamped Gmail user interface
•New Chrome browser syncs with your bookmarks, saves
pages offline, supports 16 browser tabs
•More keyboard error correction, inline spell check
•Customizable lock screen, launcher
•Recent applications icon
•Roboto typeface
•New swipe/delete behavior
•Improved voice integration and copy and paste
•Face Unlock security feature
•….and more
Introduction (cont.)
ANDROID VERSION
4.1 (Jelly Bean)
SDK RELEASE*
July 2012
8
July 17, 2015
CST594 – Mobile Computing
Android Presentation
NOTABLE UPDATES
•Faster, smoother performance with "Project Butter"
•Expandable notifications with greater interaction
•Voice search access by swiping up from bottom of the
screen
•Voice actions engine replies to some queries
•Google Now
•Offline dictation
•Default Chrome browser
•Resizable app widgets (for some)
•Android Beam support for transferring larger files,
like photo and video
•New filmstrip view of recent shots in the camera app
•Applications update in Google Play with just the
changed code
•Sound search widget for music ID
•Higher-resolution contact photos
•Greater accessibility options
•Expanded language support, especially for Arabic and
Hebrew
•Interface tweaks
Introduction (cont.)
9
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Introduction (cont.)
10
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Android
and the Hardware
Built-in Apps ≡ Apps created in SDK
Written Apps tap into resources on the device
Leverage Linux kernel to interface with hardware
Run on many different devices
Android is a software environment
Open source platform promotes development
from global community
Base OS provides simple shell environment
Apps provided by anyone or any manufactures
Introduction (cont.)
11
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Features
Handset layouts – VGA, 2D & 3D graphics library
Storage – SQLite is used for data storage
Connectivity – GSM/EDGE, CDMA, BT, Wi-Fi, LTE, NFC.
Messaging – SMS and MMS
Web browser – open-source Webkit coupled w/
Chrome’s V8 JS engine.
Java support – run on Dalvik.
Media – MPEG-4, MP3, MIDI, WAV, JPEG, PNG, GIF, etc.
Streaming media – HTML5, Adobe Flash & HTTP Dynamic
Streaming supported by Flash plugin.
Multi-touch, Multi-language, Video calling,
Multitasking, Voice based, Tethering, Screen capture,
External storage, and much more…
Introduction (cont.)
Noticeable
12
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Key Features
Pull-down notification window
Home screen widgets
Deep, rich Gmail integration
The Android market
Multiple Google account support
Google Maps Navigation
Live wallpapers
Speech-to-text
Android Beam – NFC, Google Wallet
Face unlock
Android phones
13
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Platform
Linux-based
14
July 17, 2015
CST594 – Mobile Computing
Android Presentation
OS stack for managing devices,
memory, and processes.
Android’s Java libraries cover telephony, video,
speech, graphics, connectivity, UI programming,
and other aspects.
Android SDK supports most Java Platform, Java SE.
Has own optimized JVM, Dalvik VM – to counter the
handled device limitations like memory, processor
speed, and power.
Support custom Google 2D graphics library called
Skia (written in C & C++). The 3D APIs is based on
the OpenGL ES from the Khronos group.
Platform (cont.)
Detailed Android SDK software stack
15
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Platform (cont.)
Android
16
July 17, 2015
CST594 – Mobile Computing
Android Presentation
S/W Stack – Application
Android provides a set of core applications:
Email Client
SMS Program
Calendar
Maps
Browser
Contacts
Etc
All applications are written using the Java language.
Platform (cont.)
Android
17
July 17, 2015
CST594 – Mobile Computing
Android Presentation
S/W Stack – Framework
Enabling and simplifying the reuse of components
Developers have full access to the same framework APIs
used by the core applications.
Users are allowed to replace components.
Platform (cont.)
Android
18
July 17, 2015
CST594 – Mobile Computing
Android Presentation
S/W Stack – Libraries
Including a set of C/C++ libraries used by components
of the Android system
Exposed to developers through the Android
application framework
Platform (cont.)
Android
19
July 17, 2015
CST594 – Mobile Computing
Android Presentation
S/W Stack – Runtime
Core Libraries
Providing
most of the functionality available in
the core libraries of the Java language
APIs
Data Structures
Utilities
File Access
Network Access
Graphics
Etc.
Platform (cont.)
Android
20
July 17, 2015
CST594 – Mobile Computing
Android Presentation
S/W Stack – Runtime (cont.)
Dalvik Virtual Machine
Providing environment on which every Android
application runs
Each Android application runs in its own process, with
its own instance of the Dalvik VM.
Dalvik has been written such that a device can run
multiple VMs efficiently.
Register-based
virtual machine
Platform (cont.)
21
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Dalvik
Virtual Machine (cont.)
Executing the Dalvik Executable (.dex) format
.dex format is optimized for minimal memory
footprint
Compilation
Relying on the Linux Kernel for:
Threading
Low-level memory management
Platform (cont.)
Android
22
July 17, 2015
CST594 – Mobile Computing
Android Presentation
S/W Stack – Linux Kernel
Relying on Linux Kernel 2.6 for core system
services
Memory and Process Management
Network Stack
Driver Model
Security
Providing an abstraction layer between the H/W
and the rest of the S/W stack
Platform (cont.)
23
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Android
SDK ships with Eclipse plug-in called
Android Development Tools (ADT). Use this IDE tool
for developing, debugging, & testing Java apps.
Support Android emulator
Android UI uses the new type of 4th-generation UI
framework.
Android Java API contains more than 40 packages
and more than 700 classes, & keeps growing…
Android source code is open source and managed
by the Git source code control system.
Java programmers should benefit greatly from this
general purpose computing platform!
Android Architecture
24
July 17, 2015
CST594 – Mobile Computing
Android Presentation
By
default, each
app run in its own
Linux process
Each process has
its own Dalvik VM
By default, each
app is assigned
unique Linux ID
(permissions are set
so app’s files are
only visible to that
app)
Application Components
o
Activity
o
Receive and react to broadcast announcements
Example: announcements that the time zone has changed
Content Providers
o
Run in the background for an indefinite period of time
Example: calculate and provide the result to activities that need it
Broadcast Receivers
o
Present a visual user interface for one focused endeavor the user can
undertake
Example: a list of menu items users can choose from
Services
o
25
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Store and retrieve data and make it accessible to all applications
Example: Android ships with a number of content providers for common
data types (e.g., audio, video, images, personal contact information,
etc.)
Intents
Hold the content of a message
Example: convey a request for an activity to present an image to the
user or let the user edit some text
Build Process
A
26
July 17, 2015
CST594 – Mobile Computing
Android Presentation
quick look on how an app developed from
source code to a final package on Android
devices.
IDE Setup
27
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Guideline
for installing whole environment for
developing an Android application:
Download the Android Software Development Kit (SDK)
http://developer.android.com/sdk/index.html
Provides you the API libraries and developer tools
necessary to build, test, and debug apps for Android.
This is for emulating Android on your local computer.
From the Android SDK Download Page, make sure to
choose the version that is correct for your operating
system. Extract the file and move the new folder to a
location that you know. The path will be hereby known as
$ANDROID.
IDE Setup (cont.)
28
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Download Eclipse IDE for Java Developers
http://www.eclipse.org/downloads/
From the Eclipse Downloads Page, choose the “Eclipse
IDE for Java Developers”. Make sure you are getting the
correct version for your operating system.
Extract the file and move the new folder as a sub-folder
of the $ANDROID folder.
IDE Setup (cont.)
29
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Install the Android Development Tools (ADT) plugin for Eclipse
http://developer.android.com/sdk/installing/installing-adt.html
Start Eclipse, then select Help > Install New Software.
Click Add, in the top-right corner.
In the Add Repository dialog that appears, enter "ADT Plugin" for
the Name and the following URL for the Location: https://dlssl.google.com/android/eclipse/
Click OK. (If you have trouble acquiring the plugin, try using
"http" ).
In the Available Software dialog, select the checkbox next to
Developer Tools and click Next.
In the next window, you'll see a list of the tools to be
downloaded. Click Next.
Read and accept the license agreements, then click Finish. If
you get a security warning saying that the authenticity or
validity of the software can't be established, click OK.
When the installation completes, restart Eclipse
IDE Setup (cont.)
30
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Connect Android SDK with Eclipse IDE
1. Click on the “Eclipse” menu, Windows -> Preferences
2. Click on “Android” heading in the menu-tree to open
our Android Eclipse preferences
3. Click the “Browse…” button to the right of the ”SDK
Location” box
4. Enter the location of your Android SDK (the $ANDROID
path)
IDE Setup (cont.)
31
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Install Android SDK Components
http://developer.android.com/sdk/adding-components.html
Android is packaged in such a way that the base Android SDK is
distinct and separate from each API versions of the Android
SDK. To develop an Android app, you also need to download
at least one Android platform and the latest SDK Platform-tools.
Launch the SDK Manager by double-click the SDK
Manager.exe file at the root of the Android SDK directory.
The SDK Manager shows all the SDK packages available for you
to add to your Android SDK. As a minimum configuration for
your SDK, we recommend you install the following:
The latest Tools packages (check the Tools folder).
The latest version of Android (check the first Android folder).
The Android Support Library (open the Extras folder and
check Android Support Library).
Once you've chosen your packages, click Install. The Android SDK
Manager installs the selected packages into your Android SDK
environment.
IDE Setup (cont.)
32
July 17, 2015
CST594 – Mobile Computing
Android Presentation
IDE Setup (cont.)
33
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Create Android Virtual Devices (AVDs) – Android Emulator
http://developer.android.com/guide/practices/screens_support.html#testing
An Android Virtual Device (AVD) is an emulator that mimic all of
the h/w & s/w features of a typical mobile device. The
emulator lets you prototype, develop, and test Android apps
without using the physical device.
From Eclipse, click on the Window > AVD Manager. Click New to
create a new AVD.
Choose target API Level
To test forwardcompatibility, create an
AVD with API Level higher
34
Application
Development walkthrough
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Demonstrate Eclipse
Demonstrate Java programming
Demonstrate Android Java program in Eclipse
Going over Package contents, views, manifest,
activities, and etc.
Demonstrate Android Virtual Device
35
Java
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Java
is an object-oriented language, with a
syntax similar to C
Structured around objects and methods
A method is an action or something you do with
the object
Why
Java? Avoid those overly complicated
features of C++
≠
Operator overloading, pointer, templates, friend
class, etc.
Java
Compiling
36
July 17, 2015
CST594 – Mobile Computing
Android Presentation
and Executing java program
Write java class HelloWorld containing a main()
method and save in file ”HelloWorld.java”
(The file name MUST be the same as class name)
Compile with: javac HelloWorld.java
(Creates compiled .class file: HelloWorld.class)
Run the program: java HelloWorld
(Notice: use the class name directly, no .class!)
HelloWorld in Eclipse
37
July 17, 2015
CST594 – Mobile Computing
Android Presentation
HelloWorld (cont.)
38
July 17, 2015
CST594 – Mobile Computing
Android Presentation
HelloWorld (cont.)
39
July 17, 2015
CST594 – Mobile Computing
Android Presentation
HelloWorld (cont.)
40
July 17, 2015
CST594 – Mobile Computing
Android Presentation
HelloWorld (cont.)
41
July 17, 2015
CST594 – Mobile Computing
Android Presentation
HelloWorld (cont.)
42
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Package Content
All source
codes here
All non-code
resources
43
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Java code for
our activity
Generated Java
code. Helps link
resources to
Java code
Layout of the
activity
Images
Strings used in
the program
Android
Manifest
Package (cont.)
44
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Android Manifest
45
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Android HelloWorld
46
July 17, 2015
CST594 – Mobile Computing
Android Presentation
(/gen/R.java)
package com.example.helloandroid;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int icon=0x7f020000;
}
public static final class id {
public static final int textview=0x7f050000;
}
public static final class layout {
public static final int main=0x7f030000;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
Activity File
47
July 17, 2015
CST594 – Mobile Computing
Android Presentation
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="This is my first Android Application"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="And this is a clickable button!" />
</LinearLayout>
Run on AVD
1.Click on AVD icon
2. Choose device and click start
3.Click on run
HelloWorld App
appears on
successful run
48
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Outcome
49
July 17, 2015
CST594 – Mobile Computing
Android Presentation
50
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Activity: Definition and its life cycle
public class Activity extends ApplicationContext {
protected void onCreate(Bundle savedInstanceState);
protected void onStart();
protected void onRestart();
protected void onResume();
protected void onPause();
protected void onStop();
protected void onDestroy();
}
51
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Activity: Definition and its life cycle
52
Views
July 17, 2015
CST594 – Mobile Computing
Android Presentation
53
Views
FrameLayout
Gallery
GridView
LinearLayout
ListView
RelativeLayout
ScrollView
Spinner
SurfaceView
TabHost
TableLayout
ViewFlipper
ViewSwitcher
July 17, 2015
CST594 – Mobile Computing
Android Presentation
54
Activities start each other
July 17, 2015
CST594 – Mobile Computing
Android Presentation
July 17, 2015
CST594 – Mobile Computing
Tower of Hanoi
(an Android game)
By Joanne Kuei-Chen Ho
55
Tower of Hanoi
56
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Intro to AndEngine
Free open source OpenGL ES 2 android game engine
OpenGL ES 2 - Open graphic library embedded
system version 2
Advantages:
Free and open source.
Most important aspects of every game are covered
already by engine.
You don't really need OpenGL experience (but
might be useful, obviously)
Fast and, well designed and organized engine.
Relatively big, active and helpful community.
Great engine extensions.
Plenty of examples, showing off engine capabilities.
Tower of Hanoi
57
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Intro to AndEngine Drawbacks:
There is mostly no code documentation.
Sometimes slower comparing to other engines.
Lack of documentation – difficult to start with
Has
great examples: great way to check
and understand how it works
Developer community – you might always
expect help from different developers
Tower of Hanoi
58
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- AndEngine Core Features
Engine:
Controls the whole game; synchronize and update
the Scenes
IResolutionPolicy:
It tells the engine about how to deal with the
different resolutions of different devices.
RatioResolutionPolicy - keep everything scaled in
in proper ratio (disadvantage - black lines might
occur)
FillResolutionPolicy - fill whole resolution
(disadvantage - images might be stretched)
Tower of Hanoi
59
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- AndEngine Core Features
Camera:
Scene:
A Camera defines the rectangle of the scene that is drawn on
the screen, as not the whole scene is visible all the time. Usually
there is one Camera per Scene. There are subclasses with more
functions, example:
BoundCamera - you might specify bounds for your scene.
ZoomCamera - you might enable zooming, pinch zoom, and
scrolling camera.
The root container for all objects to be drawn on the screen.
Has a specific amount of Layers, which themselves can contain
a (fixed or dynamic) amount of Entities.
Entity:
An Entity is an object that can be drawn, like Sprites,
Rectangles, Text or Lines; has a position/scale/color/etc.
Sprite - entity with texture
Tower of Hanoi
60
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- AndEngine Core Features
Texture:
A Texture is an 'image' in the memory of the graphics
pool.
On Android, the width and height of a Texture has to be
a power of 2 (in latest GLES2 this rule is not required, so its
really useful to reduce memory usage) Therefore
AndEngine assembles a Texture from a couple of
ITextureSources, so the space can be used better.
TextureRegion:
Defines a rectangle on the Texture, used by Sprites to let
the system know what part of the big Texture the Sprite is
showing.
Tower of Hanoi
61
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- AndEngine StructureBaseGameActivity
Engine
Scene
Entities
Textures
Camera
Tower of Hanoi
- AndEngine Lifecycle-
62
July 17, 2015
CST594 – Mobile Computing
Android Presentation
onCreateEngineOptions()
onCreateResources()
onCreateScene()
63
Tower of Hanoi (example)
July 17, 2015
CST594 – Mobile Computing
Android Presentation
Tower of Hanoi
64
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Structure of the example Main.java (BaseGameActivity)
SceneManager
Engine
Splash
Scene
Menu
Scene
MainGame
Scene
Entities
Entities
Entities
Textures
Textures
Textures
Tower of Hanoi
65
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Getting Started
Now that you know a bit more about AndEngine, it’s time
to download the source code and set up the environment.
Note: Since AndEngine is hosted on GitHub, you could
always clone the git repository for AndEngine to get the
source code for the project. However, this requires that
you have git installed on your machine and that you are
able to work on the command line.
Open up your browser and go to the AndEngine github
page. You should see a link on the page to download the
repository as a ZIP file. Use that to download a copy of the
AndEngine project. Or, you should be able to use this link to
download the file directly.
Extract the downloaded ZIP file to a convenient location on
your hard drive.
Tower of Hanoi
66
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Getting Started
Now that you’ve got the source code for the game
engine, if you want, you can also download the code
for additional AndEngine extensions. In this tutorial,
you will not be using any of the extensions but you will
need all of them in place if you wanted to try out the
AndEngine sample project, which is also available on
GitHub.
The sample project is a great way to learn the
different ways to use AndEngine and you can always
get the latest sample project and the extensions by
downloading each of them from GitHub, setting up
the projects, and building the sample
Tower of Hanoi
67
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Setting up the environment
Before you start coding, there are a few things you should know about
AndEngine:
OpenGL ES 2.0: The currently developed version of AndEngine is the
GLES 2.0 version. This version requires OpenGL ES 2.0 support in
order to function. So you need to make sure that your device (or
emulator) supports OpenGL ES 2.0. If you are using the emulator to
test, then you need graphics acceleration support and this is there
only in the latest SDK Tools version. As of this tutorial, the latest SDK
Tools version available is revision 19. Make sure that you have at
least this version installed. To upgrade, please follow the instructions
given here.
Android 4.0.3: You also need Android SDK Platform API 15, Revision
3 or higher in order to test OpenGL ES 2.0 based code on the
emulator. So make sure that you’ve upgraded to at least Android
4.0.3, which is API 15. You emulator used for testing AndEngine
code should be using Android 4.0.3.
Emulator: If you are using the emulator to test AndEngine code, you
need a virtual device which has GPU emulation enabled and is
running at least Android 4.0.3. So check your virtual device
configuration and edit it if your device is not set up appropriately.
Tower of Hanoi
68
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Setting up the environment
With that done, it’s time to start Eclipse, the IDE usually used for
Android development. So go ahead an start Eclipse.
The version of AndEngine that you downloaded from GitHub
already contains an Eclipse project file. You can simply import
that by going to File->Import …
Select “Existing Projects into Workspace” from the dialog and
click “Next”. A new dialog should open where you must
specify the location of the AndEngine project.
Click the “Browse” button and browse to the folder where you
extracted the AndEngine source ZIP file. The existing project
should be detected and show up automatically in the dialog.
Click “Finish”. And you should have the project imported into
your Eclipse workspace – it’s that simple :]
If by some chance the extracted source is missing the Eclipse
project information, you can create a new project by going to
File->New->Project. A window like the one shown in the image
below will open. Select Android Project and click Next.
Tower of Hanoi
69
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Setting up the environment
Give the project a name: I suggest sticking with
“AndEngine.” or “AndEngine Library”.
Select the “Create project from existing source”
option. Next click the browse button, go to the
location of the AndEngine source code and select
Open. Once you’ve found the right location, press
Finish. This will create a new project called AndEngine
(or AndEngine Library) that you can view in the project
navigator.
Your AndEngine library project is now ready. This way,
you can add your AndEngine (library) project as a
library to your tutorial project and the AndEngine
library will be compiled in as part of your project.
Tower of Hanoi
70
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- How to learn AndEngine There
is no official documentation
The forums are hit or miss
There are a few YouTube videos
Your
best bet is to find an example closest to
your desired outcome and reverse engineer it
Oddly enough, it works pretty well!
July 17, 2015
CST594 – Mobile Computing
KnockKnock Client
(A client/server demo)
By Ray Hedgecock
71
KnockKnock Client
(an example)
72
July 17, 2015
CST594 – Mobile Computing
Android Presentation
KnockKnock Client
73
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Outline This client/server app demonstrates the following:
Client/Server pattern (Java)
o Socket/ServerSocket use (Java)
o Threads in Android
o Async Task in Android
o Event listeners
o Handlers (Android)
o Loopers (Android)
o Inner classes
o
KnockKnock Client
74
July 17, 2015
CST594 – Mobile Computing
Android Presentation
- Basis for Demo The knock knock client is based on a
Java tutorial that can be found on the
Oracle website at:
http://docs.oracle.com/javase/tutorial/networking/sockets/clientServer.html
The tutorial is on how to implement the
basic Java client/server pattern.
KnockKnock Client
- App Demo -
75
July 17, 2015
CST594 – Mobile Computing
Android Presentation
KnockKnock Client
- KKMultiServer -
76
July 17, 2015
CST594 – Mobile Computing
Android Presentation
KnockKnock Client
- KKClient -
77
July 17, 2015
CST594 – Mobile Computing
Android Presentation
July 17, 2015
CST594 – Mobile Computing
Google Maps and
Location Services
By Agastheswar
78
Google Maps
79
July 17, 2015
CST594 – Mobile Computing
Android Presentation
-What can we do with Google Maps
Build
Location based Applications
Visualize Geospatial Data
Customize maps
Build maps for Mobile apps
-API’s for Google Maps
Maps
Android API
Places API
Google Earth API
Map Image API
Google Maps
80
July 17, 2015
CST594 – Mobile Computing
Android Presentation
-How to enable Google Maps on android
Download
and Configure Google Play services
Obtain API key for Google maps
Specify Settings to Application Manifest
Adding Map to main activity
Publish the Application
Google Maps
-Map Types
81
July 17, 2015
CST594 – Mobile Computing
Android Presentation
-Drawing on Map
Normal
Markers
Hybrid
Polygons
Terrain
polylines
and
None
-Map Objects
Map
Fragment
Map View
-Changing the view
Change
camera
Position
Moving the
camera
References
82
July 17, 2015
CST594 – Mobile Computing
Android Presentation
http://en.wikipedia.org/wiki/Android_(operating_system)#Descr
iption
http://kschang.hubpages.com/hub/Cupcake-Donut-EclairFroyo-Gingerbread-Honeycomb-Android-OS-VersionCodenames-and-Why
http://en.wikipedia.org/wiki/Android_version_history
http://reviews.cnet.com/8301-19736_7-20012566-251/theandroid-era-from-g1-to-jelly-bean/
Ableson, Frank; Collins, Charlie; Sen, Robi. Unlocking Android, A
Developer’s Guide. Greenwich: Manning Publications Co. 2009.
http://developer.android.com/about/dashboards/index.html
androidgroup.googlecode.com/files/Unlocking%20Android.pdf
http://www.androidphonesarena.com/2012-androidphones.php
http://developer.android.com/guide/components/fundament
als.html
http://www.engadget.com/2011/04/07/gartner-androidgrabbing-over-38-percent-of-smartphone-market-i/
References (cont.)
83
July 17, 2015
CST594 – Mobile Computing
Android Presentation
http://translate.google.com.hk/translate?hl=en&ie=UTF8&prev=
_t&sl=zhCN&tl=en&u=http://data.eguan.cn/yidonghulian_147283.html
http://ecee.colorado.edu/ecen3000/lecture/introduction.pdf
http://www.android-app-market.com/android-applicationcomponents.html
http://www.techjini.com/blog/category/software/
http://www.hongkiat.com/blog/android-evolution/
http://cdn.cs76.net/2012/spring/lectures/3/lecture3-dan.pdf
http://developer.android.com/sdk/installing/installing-adt.html
http://developer.android.com/
Beginning Android Application Development (Lee, Wei-Meng)
https://developers.google.com/maps/documentation/android
July 17, 2015
CST594 – Mobile Computing
84