Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Android
(and SVN)
lecture
Delphine Szymczak
Certec,
Department of Design Sciences
Lund University
October 30, 2012
Outline
1 Android Operating System
2 Applications and Flow in Android
Activities
Services
Intents
3 Tools
Android SDK
Debugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Outline
1 Android Operating System
2 Applications and Flow in Android
Activities
Services
Intents
3 Tools
Android SDK
Debugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Android
What are we talking about?
I
An Open Platform for Mobile Development
I
NOT a mobile phone
I
a package of preinstalled applications
I
a software development kit used to create applications
I
a free mobile Operating System
I
builds on a Linux Kernel, but not a Linux OS : a full set of std
Linux utilities not included
I
development possible from different platforms (Windows,
Linux, Mac) using Java
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Android OS
System Architecture
I
C++ below Dalvik, Java above
I
abstraction layers
I
code at applications level and
call on the application
framework
http://source.android.com/tech/security/
I
Process isolation
I
Application-defined and user-granted permissions
(in AndroidManifest.xml)
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Outline
1 Android Operating System
2 Applications and Flow in Android
Activities
Services
Intents
3 Tools
Android SDK
Debugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Applications in Android
I
A collection of one or more tasks (activities or services) plus a
Linux process to contain them
I
Multiple applications can run concurrently
I
Can be interrupted and paused when events occur
I
Only one visible application at a time
I
Either an Activity with a visible screen ...
I
...or a Service without a graphical user interface
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Activities in Android
Visible screen in the application
I
A task or purpose
I
A user interface screen
I
It has its own life cycle
They extend the Context class (you can get global info about
your application) http://developer.android.com/reference/
I
android/content/Context.html
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Activities in Android
An activity’s lifecycle
Some @Override methods
I
onCreate() Creates the layout,
data binding, contentview
I
onResume() Appropriate place
to load resources (e.g. starting
audio, video...)
I
onPause() e.g. stop audio,
video started at onResume()
Need to return before a new
foreground Activity can start.
I
onStop() and onDestroy()
might not be executed at all
(before version 3.0 Honeycomb)
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Activities in Android
Restoring a killed activity
Your activity can be killed to retrieve memory resources when it is
not in the foreground. The last method executed before it is
killable is onPause() (<3.0) or onStop() for later versions.
More on Activities at :
http://developer.android.com/guide/components/activities.html
http://developer.android.com/reference/android/app/Activity.html
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Services in Android
I
A task that works in the background (similar to a daemon)
I
Runs on the same process as the application it is part of.
I
Is not a Thread
I
No user direct interaction (but can be used to handle
non-graphical interaction, e.g. sensor-based)
I
Clients may bind to a service
More on Services at :
http://developer.android.com/guide/components/services.html
http://developer.android.com/reference/android/app/Service.html
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Services in Android
A service’s lifecycle
Some methods
I
onCreate() initial setup
I
onStartCommand() or
onBind() Start the active
lifetime of a service. They take
an Intent in parameter.
onStart() before version 2.0
I
onDestroy() release all
resources
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Intents in Android
The Message Mechanism
I
An asynchronous message system that can be used to pass
data between activities.
I
Describes a specific action
I
What’s your intention? Send mail, Open the browser, Start
the camera...
I
Possibility to send information through ”extras” (parcelable or
serializable)
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Intents in ”The Zero App”
Connecting to Services, Calling Activities
I
Intent intent = new Intent(this, TimeCounter.class);
startActivity(intent);
I
Intent question = new Intent(this, JustAnAnswer.class);
startActivityForResult(question, MY POSITION);
I
onActivityResult(int requestCode, int resultCode, Intent
data) { if(requestCode == MY POSITION) ...
I
Intent service = new Intent(AidDemo.this,
MyCurrentLocation.class);
bindService(service, mServiceConnection,
Context.BIND AUTO CREATE);
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Intents in ”The Zero App”
Using Extras
I
Intent answer = new Intent();
answer.putExtra(”se.lth.certec.aiddemo.lat”,
currentLocation.getLatitude());
answer.putExtra(”se.lth.certec.aiddemo.lon”,
currentLocation.getLongitude());
I
@Override
protected void onActivityResult(int requestCode, int resultCode,
Intent data) {...
double latitude =
data.getExtras().getDouble(”se.lth.certec.aiddemo.lat”);
double longitude =
data.getExtras().getDouble(”se.lth.certec.aiddemo.lon”);
Note the format to refer to strings (\res\values\string.xml).
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Outline
1 Android Operating System
2 Applications and Flow in Android
Activities
Services
Intents
3 Tools
Android SDK
Debugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Android SDK
Some of the available features
Interesting available methods
I
APIs for location-based services, such as GPS
I
Multimedia hardware control such as playback, recording,
camera, etc.
I
APIs for sensors, such as accelerometer and compass
I
and more to try out...
A useful tool
I
Integration with Eclipse
I
Emulators of an Android device (but limited for sensor use)
I
Handling versions of Android and relevant tools
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Debugging with the DDMS
Dalvik Debug Monitor Service
I
I
Launched in Eclipse or as a
standalone, a window with
messages displayed in real
runtime from devices.
System.out.print / Log.*
I
I
I
Errors :
Log.e(”title”, ”message)
Warnings, Information,
Debug, Verbose
Screen capture, and more useful
real time information.
http://developer.android.com/tools/debugging/ddms.html
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Outline
1 Android Operating System
2 Applications and Flow in Android
Activities
Services
Intents
3 Tools
Android SDK
Debugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Haptimap toolkit
an overview
The purpose of the toolkit is to make it easier for developers of
mobile applications to incorporate accessible design and
functionality into applications of maps and LBS.
The toolkit explores the available hardware on the mobile device
(e.g., monitor, speakers and motor) to provide alternative access to
map and LBS data through vision, hearing or touch. The main
advantage of the toolkit is that it provides a simple cross-platform
API that abstracts the complexities of
I
dealing with haptic / audio / visual input and output on a
cross-platform basis
I
retrieving, storing and manipulating geographic data
http://www.haptimap-training.org/HaptimapToolkitTraining/
Toolkit/Overview.cshtml
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Haptimap toolkit Architecture
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkit
example : Haptic Guide HCI
Vibration pattern more
frequent when closer to
target.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkit
example : Audio Guide HCI
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkit
example : Speech Guide HCI
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkit
example : Scan Orientation HCI
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkit
example : Sound Bubbles HCI
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Outline
1 Android Operating System
2 Applications and Flow in Android
Activities
Services
Intents
3 Tools
Android SDK
Debugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Demo and questions
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Outline
1 Android Operating System
2 Applications and Flow in Android
Activities
Services
Intents
3 Tools
Android SDK
Debugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Introduction to Subversion
a version control solution
I
Keep a history through incremental versions
I
One central folder (repository) on a server
I
Local versions (working copy) can be
downloaded (checkout) and synchronized
(update)
I
Local changes can be sent (commit) to the
central repository
I
ref. http://svnbook.red-bean.com/
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
SVN revisions
Keeping a history of changes
I
Each change, when sent to the server gets
numbered.
I
The server (central repository) keeps the
history of revisions.
I
Usually you work on the last revision.
I
It is possible to look at specific changes
between revisions (diff), and tools exist for
text files (e.g. myCode.java)
I
It is possible to get to those earlier versions,
branch out parts or all of the code.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
SVN conflicts
A conflict : concurrent
editions of files
Update is required
before any conflicting
change.
We could lock the files...
difficult collaboration.
In SVN, the solution is
based on
copy-modify-merge.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Project folders
Recommended organization
I
”trunk” folder for the main code area
I
”tag” folder for snapshots of the project (milestones in the
revision history)
I
”branches” for parts of the project that have been forked
(could be merged back)
I
.svn ? This is where are kept information about what has
been locally changed and needs to be committed, or about
which version of each file we have locally.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
List of SVN Commands I
communication with the server and good practices
I
”checkout” takes the repository adress as argument and may
require a login. It downloads the repository in an empty folder.
Latest version as default, but you can choose earlier ones.
I
”update” downloads the changes from the repository to your
local copy. It is required to be up to date on any part your are
modifying before sending your changes.
I
”add, delete, copy, move” files with the appropriate SVN
commands. Deleting a file from your local copy without using
the SVN command will not delete it on the server. A file
created also needs to be ”added” through the SVN command
if one wants it on the repository.
I
Changes within a file can be made directly. Files that differ
from the central version will be included in the next commit.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
List of SVN Commands II
communication with the server and good practices
I
Review your changes before sending. diff tools are provided
for text files, line-by-line comparison is possible. A list of
actions (files added or deleted) can also be obtained.
I
”revert” can be used to change back a file to a specific
unmodified revision version.
I
Resolving conflicts at update or merge : It happens because
you have local changes that conflict with the files that you are
updating. Inspect the differences and decide.
I
”commit” publishes your changes. Other users can then
download (update) them. Write informative messages when
you commit. It serves as documentation when going through
the history.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Questions on SVN
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH