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 AndroidActivitiesServicesIntents
3 ToolsAndroid SDKDebugging - 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 AndroidActivitiesServicesIntents
3 ToolsAndroid SDKDebugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
AndroidWhat 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 stdLinux 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 OSSystem Architecture
I C++ below Dalvik, Java above
I abstraction layers
I code at applications level andcall on the applicationframework
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 AndroidActivitiesServicesIntents
3 ToolsAndroid SDKDebugging - 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 aLinux 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 AndroidVisible screen in the application
I A task or purpose
I A user interface screen
I It has its own life cycleI They extend the Context class (you can get global info about
your application) http://developer.android.com/reference/
android/content/Context.html
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Activities in AndroidAn activity’s lifecycle
Some @Override methods
I onCreate() Creates the layout,data binding, contentview
I onResume() Appropriate placeto load resources (e.g. startingaudio, video...)
I onPause() e.g. stop audio,video started at onResume()Need to return before a newforeground 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 AndroidRestoring a killed activity
Your activity can be killed to retrieve memory resources when it isnot in the foreground. The last method executed before it iskillable 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 handlenon-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 AndroidA service’s lifecycle
Some methods
I onCreate() initial setup
I onStartCommand() oronBind() Start the activelifetime of a service. They takean Intent in parameter.onStart() before version 2.0
I onDestroy() release allresources
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Intents in AndroidThe Message Mechanism
I An asynchronous message system that can be used to passdata between activities.
I Describes a specific action
I What’s your intention? Send mail, Open the browser, Startthe camera...
I Possibility to send information through ”extras” (parcelable orserializable)
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, Intentdata) { 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 @Overrideprotected 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 AndroidActivitiesServicesIntents
3 ToolsAndroid SDKDebugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Android SDKSome 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 DDMSDalvik Debug Monitor Service
I Launched in Eclipse or as astandalone, a window withmessages displayed in realruntime from devices.
I System.out.print / Log.*I Errors :
Log.e(”title”, ”message)I Warnings, Information,
Debug, Verbose
I Screen capture, and more usefulreal 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 AndroidActivitiesServicesIntents
3 ToolsAndroid SDKDebugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Haptimap toolkitan overview
The purpose of the toolkit is to make it easier for developers ofmobile applications to incorporate accessible design andfunctionality 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 tomap and LBS data through vision, hearing or touch. The mainadvantage of the toolkit is that it provides a simple cross-platformAPI that abstracts the complexities of
I dealing with haptic / audio / visual input and output on across-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 Toolkitexample : Haptic Guide HCI
Vibration pattern morefrequent when closer totarget.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkitexample : Audio Guide HCI
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkitexample : Speech Guide HCI
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkitexample : Scan Orientation HCI
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Modules in the Haptimap Toolkitexample : Sound Bubbles HCI
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Outline
1 Android Operating System
2 Applications and Flow in AndroidActivitiesServicesIntents
3 ToolsAndroid SDKDebugging - 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 AndroidActivitiesServicesIntents
3 ToolsAndroid SDKDebugging - DDMS
4 Haptimap toolkit
5 Demo
6 SVN - subversion repositories
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Introduction to Subversiona version control solution
I Keep a history through incremental versions
I One central folder (repository) on a server
I Local versions (working copy) can bedownloaded (checkout) and synchronized(update)
I Local changes can be sent (commit) to thecentral repository
I ref. http://svnbook.red-bean.com/
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
SVN revisionsKeeping a history of changes
I Each change, when sent to the server getsnumbered.
I The server (central repository) keeps thehistory of revisions.
I Usually you work on the last revision.
I It is possible to look at specific changesbetween revisions (diff), and tools exist fortext 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 : concurrenteditions of files
We could lock the files...difficult collaboration.In SVN, the solution isbased oncopy-modify-merge.
Update is requiredbefore any conflictingchange.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
Project foldersRecommended organization
I ”trunk” folder for the main code area
I ”tag” folder for snapshots of the project (milestones in therevision 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 hasbeen locally changed and needs to be committed, or aboutwhich version of each file we have locally.
Delphine Szymczak, Android and SVN lecture, Advanced Interaction Design course, LTH
List of SVN Commands Icommunication with the server and good practices
I ”checkout” takes the repository adress as argument and mayrequire 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 yourlocal copy. It is required to be up to date on any part your aremodifying before sending your changes.
I ”add, delete, copy, move” files with the appropriate SVNcommands. Deleting a file from your local copy without usingthe SVN command will not delete it on the server. A filecreated also needs to be ”added” through the SVN commandif one wants it on the repository.
I Changes within a file can be made directly. Files that differfrom 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 IIcommunication with the server and good practices
I Review your changes before sending. diff tools are providedfor text files, line-by-line comparison is possible. A list ofactions (files added or deleted) can also be obtained.
I ”revert” can be used to change back a file to a specificunmodified revision version.
I Resolving conflicts at update or merge : It happens becauseyou have local changes that conflict with the files that you areupdating. Inspect the differences and decide.
I ”commit” publishes your changes. Other users can thendownload (update) them. Write informative messages whenyou commit. It serves as documentation when going throughthe 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