SlideShare a Scribd company logo
1 of 23
Android Programming


Workshop in University College Ghent
         Ismo Harjunmaa
Content of the Workshop:
1. How android programming differs from plain
   Java programming
2. Tools for developers
3. Making Hello World
4. Making simple game
5. Deploying application to Android device
6. Publishing application in Adnroid Marketplace


                                                     2
Ismo Harjunmaa – Workshop Gent                 9.2.2012
Folder structure of Android project
                                .java Source files are in src-folder
                                R.java resource class in gen-folder
                                Fonts etc. in assets-folder
                                Project specific resources res-folder
                                Graphic files in drawable-folders
                                Vertical UI layout in layout-folder
                                User-interface texts, tables, styles
                                 and colors in values-folder
                                                                         3
Ismo Harjunmaa – Workshop Gent                                     9.2.2012
Activity-class
 The core of your application
 All the event handlers are implemented in this
  class (these classes)




                                                     4
Ismo Harjunmaa – Workshop Gent                 9.2.2012
UI layout in XML-file
 By default main.xml file is created in folder
  res/layout
 All the User Interface elements are described in
  XML-file
 Root element is the layout and there is eight
  different ones to pick from




                                                      5
Ismo Harjunmaa – Workshop Gent                  9.2.2012
Designing UI layout
 UI is designed in
  Eclipse either in
  graphical layout
  view or writing
  elements with
  attributes to
  main.xml
 Elements are placed
  by dragging them
  from library
                                       6
Ismo Harjunmaa – Workshop Gent   9.2.2012
Description file AndroidManifest.xml
 The most important description file
  AndroidManifest.xml is created in the root
  folder of your project
 In this file you can specify level of the API,
  screen resolution support, testing methods,
  permissions etc.
 Eclipse shows the attributes of the file either in
  plain text or selection fields

                                                         7
Ismo Harjunmaa – Workshop Gent                     9.2.2012
Content of the Workshop:
1. How android programming differs from plain
   Java programming
2. Tools for developers
3. Making Hello World
4. Making simple game
5. Deploying application to Android device
6. Publishing application in Adnroid Marketplace


                                                     8
Ismo Harjunmaa – Workshop Gent                 9.2.2012
DDMS (Dalvik Debug Monitor Server)
 Perspective in Eclipse that shows all running
  emulators or device
 Inside this perspective is a view where you can
  emulate incoming call, SMS or GPS-signal
 In this perspective you can browse the folder
  structure of the emulator or device




                                                      9
Ismo Harjunmaa – Workshop Gent                  9.2.2012
Android-SDK command-line tools
 All of the tools that Eclipse uses are actually in
  the Android-SDK as command-line tools
 One command-line tool is NOT in Eclipse: adb
  (Android Debug Bridge)
 With adb you can list processes, connect to
  SQLite databases etc.




                                                        10
Ismo Harjunmaa – Workshop Gent                     9.2.2012
Tools for developers: LogCat
 Developer needs to know bit more what is the
  state of the application
 Under folder android-sdk/platform-tools is the
  adb command
 Adb logcat shows the logs that device has output




                                                   11
Ismo Harjunmaa – Workshop Gent                9.2.2012
Tools for developers: LogCat
 In the code you use logs like this:


import android.util.Log;

private static final String TAG = 
HelloWorldActivity.class.getSimpleName();
Log.d(TAG, ”This is DEBUG level msg”);
Log.e(TAG, ”This is ERROR level msg”);
                                             12
Ismo Harjunmaa – Workshop Gent          9.2.2012
Tools for developers: traceview
 Writes full log from all events into SD-card
 Remember to choose SD-card size when creating
  the AVD
 Application needs permission to write external
  file
 Permissions are given in the applications
  AndroidManifest.xml -file
 After the trace file is commited traceview is the
  tool to analyze the trace file
                                                    13
Ismo Harjunmaa – Workshop Gent                 9.2.2012
Tools for developers: draw9patch
 Application windows have frames which consists
  nine pieces: upper-left corner, top... etc.
 So called patch dividing tool is installed with
  Android SDK
 Before using the tool you have to draw button,
  window or frame in drawing tool like photoshop
 Go to Android­sdk/tools folder and open
  draw9patch

                                                    14
Ismo Harjunmaa – Workshop Gent                9.2.2012
Tools for developers: zipalign
 If you are NOT using Eclipses ADT Plug-in, you
  have to run zipalign tool which compacts the
  APK-package




                                                        15
Ismo Harjunmaa – Workshop Gent                     9.2.2012
Tools for developers: sqlite3
 In the android-SDK package there is SQLite3
  database ready-to-use
    public class DatabaseHelper extends SQLiteOpenHelper {
                 private static String DATABASE_NAME = "SensorGame";
                 private static int DATABASE_VERSION = 3;


                 public DatabaseHelper(Context context, String name, 
                                CursorFactory factory,int version) {
                           super(context, DATABASE_NAME, null, 
                                   DATABASE_VERSION);
                 }
                     ...
                                                                        16
Ismo Harjunmaa – Workshop Gent                                     9.2.2012
Content of the Workshop:
1. How android programming differs from plain
   Java programming
2. Tools for developers
3. Making Hello World
4. Making simple game
5. Deploying application to Android device
6. Publishing application in Adnroid Marketplace


                                                    17
Ismo Harjunmaa – Workshop Gent                 9.2.2012
Making Hello World
 Open Eclipse
 Choose from menu:
  File > New... > Android Project
 Choose Build Target from option list:
  Android 3.X Android Open Source Project
 Open main.xml from folder res/layout
 While on Graphical Layout view drag
  TextView-element on the layout and set text
                                                 18
Ismo Harjunmaa – Workshop Gent              9.2.2012
Media player
   Found in package android.media
   Can play music or video
   Played resources are positioned in res/raw folder
   Common methods are available
     playing: play()
     pausing: pause()
     stopping: stop()

                                                       19
Ismo Harjunmaa – Workshop Gent                    9.2.2012
Sensors in Android Device
 From version 1.6: Light, Proximity, Temperature,
  Pressure, Gyroscope, Accelerometer, Magnetic
  field, Orientation
 From version 2.3: Gravity, Linear acceleration,
  Rotation vector, Near Field Communication
 Not all of them are in your device
 SensorManager is the class which controls the
  sensors

                                                     20
Ismo Harjunmaa – Workshop Gent                 9.2.2012
Making simple game
 Create another Android project:
  File > New... > Android Project
 Drag three textViews and three seekBars onto
  the main.xml
 Give names for views and bars like XView, XBar,
  YView, YBar... so you can reference them



                                                    21
Ismo Harjunmaa – Workshop Gent                9.2.2012
Making simple game
 In this example we are using Acceleration sensor
 Use the SensorManager to create the
  acceleration sensor
 For using sensor you have to first register the
  sensor and on leave unregister




                                                    22
Ismo Harjunmaa – Workshop Gent                 9.2.2012
References
 Komatinemi, MacLean & Hashimi: Pro Android 3

More Related Content

Viewers also liked

1º Termômetro IBOPE / LIDE MULHER
1º Termômetro IBOPE / LIDE MULHER1º Termômetro IBOPE / LIDE MULHER
1º Termômetro IBOPE / LIDE MULHERLIDE Pernambuco
 
Inn530 developing social media strategy for gemtree
Inn530   developing social media strategy for gemtreeInn530   developing social media strategy for gemtree
Inn530 developing social media strategy for gemtreeAleksCheung
 
La enseñanza de la historia de venezuela
La enseñanza de la historia de venezuelaLa enseñanza de la historia de venezuela
La enseñanza de la historia de venezuelafanny Avila
 
El niño con el pijama a rayas. análisis antropológico
El niño con el pijama a rayas. análisis antropológicoEl niño con el pijama a rayas. análisis antropológico
El niño con el pijama a rayas. análisis antropológicoTomas Gibert
 
Poligami menurut islam
Poligami menurut islamPoligami menurut islam
Poligami menurut islammhd amin omar
 
De dynamiek van verandering | Target Point, Guide to Change
De dynamiek van verandering | Target Point, Guide to ChangeDe dynamiek van verandering | Target Point, Guide to Change
De dynamiek van verandering | Target Point, Guide to ChangeAngela van de Loo
 
Cada año nos embarcamos en un nuevo proyecto teatral
Cada año nos embarcamos en un nuevo proyecto teatralCada año nos embarcamos en un nuevo proyecto teatral
Cada año nos embarcamos en un nuevo proyecto teatralAlfonso Cortes Alegre
 
Lengua y literatura 2
Lengua y literatura 2Lengua y literatura 2
Lengua y literatura 2Luis Vidal
 
Al fiqh alislami nafaqah & hadhanah
Al fiqh alislami nafaqah & hadhanahAl fiqh alislami nafaqah & hadhanah
Al fiqh alislami nafaqah & hadhanahShamsila Nazman
 
Poemas sin rimas. escritura creativa
Poemas sin rimas. escritura creativaPoemas sin rimas. escritura creativa
Poemas sin rimas. escritura creativaA. Galindo.
 
Lesson template
Lesson templateLesson template
Lesson templateanoop kp
 

Viewers also liked (18)

1º Termômetro IBOPE / LIDE MULHER
1º Termômetro IBOPE / LIDE MULHER1º Termômetro IBOPE / LIDE MULHER
1º Termômetro IBOPE / LIDE MULHER
 
Ideas maquilladoras
Ideas maquilladorasIdeas maquilladoras
Ideas maquilladoras
 
Tabletas en la educación.
Tabletas en la educación.Tabletas en la educación.
Tabletas en la educación.
 
Inn530 developing social media strategy for gemtree
Inn530   developing social media strategy for gemtreeInn530   developing social media strategy for gemtree
Inn530 developing social media strategy for gemtree
 
La enseñanza de la historia de venezuela
La enseñanza de la historia de venezuelaLa enseñanza de la historia de venezuela
La enseñanza de la historia de venezuela
 
innovative learning methods
innovative learning methodsinnovative learning methods
innovative learning methods
 
El niño con el pijama a rayas. análisis antropológico
El niño con el pijama a rayas. análisis antropológicoEl niño con el pijama a rayas. análisis antropológico
El niño con el pijama a rayas. análisis antropológico
 
Poligami menurut islam
Poligami menurut islamPoligami menurut islam
Poligami menurut islam
 
COLABORADORES PA
COLABORADORES PACOLABORADORES PA
COLABORADORES PA
 
De dynamiek van verandering | Target Point, Guide to Change
De dynamiek van verandering | Target Point, Guide to ChangeDe dynamiek van verandering | Target Point, Guide to Change
De dynamiek van verandering | Target Point, Guide to Change
 
Cada año nos embarcamos en un nuevo proyecto teatral
Cada año nos embarcamos en un nuevo proyecto teatralCada año nos embarcamos en un nuevo proyecto teatral
Cada año nos embarcamos en un nuevo proyecto teatral
 
II El escritorio eTwinning Live
II El escritorio eTwinning LiveII El escritorio eTwinning Live
II El escritorio eTwinning Live
 
Lecturas
LecturasLecturas
Lecturas
 
Lengua y literatura 2
Lengua y literatura 2Lengua y literatura 2
Lengua y literatura 2
 
Al fiqh alislami nafaqah & hadhanah
Al fiqh alislami nafaqah & hadhanahAl fiqh alislami nafaqah & hadhanah
Al fiqh alislami nafaqah & hadhanah
 
Dulce problema
Dulce problemaDulce problema
Dulce problema
 
Poemas sin rimas. escritura creativa
Poemas sin rimas. escritura creativaPoemas sin rimas. escritura creativa
Poemas sin rimas. escritura creativa
 
Lesson template
Lesson templateLesson template
Lesson template
 

Similar to Android basics

Java talks. Android intoduction for develompment
Java talks. Android intoduction for develompmentJava talks. Android intoduction for develompment
Java talks. Android intoduction for develompmentAlexei Miliutin
 
Session 2 prepare android development environment
Session 2   prepare android development environmentSession 2   prepare android development environment
Session 2 prepare android development environmentAdham Enaya
 
Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorialMohammad Taj
 
Introduction to Android Development Part 1
Introduction to Android Development Part 1Introduction to Android Development Part 1
Introduction to Android Development Part 1Kainda Kiniel Daka
 
Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorialnazzf
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Ahsanul Karim
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recieversJagdish Gediya
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to androidzeelpatel0504
 
Android developer interview questions with answers pdf
Android developer interview questions with answers pdfAndroid developer interview questions with answers pdf
Android developer interview questions with answers pdfazlist247
 
Google android white paper
Google android white paperGoogle android white paper
Google android white paperSravan Reddy
 
Android development training programme Day 1
Android development training programme Day 1Android development training programme Day 1
Android development training programme Day 1DHIRAJ PRAVIN
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentAhsanul Karim
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studioParinita03
 
Android For Java Developers
Android For Java DevelopersAndroid For Java Developers
Android For Java DevelopersMike Wolfson
 
Installing eclipse & sdk
Installing eclipse & sdkInstalling eclipse & sdk
Installing eclipse & sdkArun Kumar
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answerskavinilavuG
 

Similar to Android basics (20)

Java talks. Android intoduction for develompment
Java talks. Android intoduction for develompmentJava talks. Android intoduction for develompment
Java talks. Android intoduction for develompment
 
Session 2 prepare android development environment
Session 2   prepare android development environmentSession 2   prepare android development environment
Session 2 prepare android development environment
 
Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorial
 
Introduction to Android Development Part 1
Introduction to Android Development Part 1Introduction to Android Development Part 1
Introduction to Android Development Part 1
 
Android development tutorial
Android development tutorialAndroid development tutorial
Android development tutorial
 
Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3Android Workshop: Day 1 Part 3
Android Workshop: Day 1 Part 3
 
Android activity, service, and broadcast recievers
Android activity, service, and broadcast recieversAndroid activity, service, and broadcast recievers
Android activity, service, and broadcast recievers
 
Introduction to android
Introduction to androidIntroduction to android
Introduction to android
 
Android developer interview questions with answers pdf
Android developer interview questions with answers pdfAndroid developer interview questions with answers pdf
Android developer interview questions with answers pdf
 
Android basics
Android basicsAndroid basics
Android basics
 
Google android white paper
Google android white paperGoogle android white paper
Google android white paper
 
Android development training programme Day 1
Android development training programme Day 1Android development training programme Day 1
Android development training programme Day 1
 
Day: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application DevelopmentDay: 2 Environment Setup for Android Application Development
Day: 2 Environment Setup for Android Application Development
 
Session 2 beccse
Session 2 beccseSession 2 beccse
Session 2 beccse
 
Creating the first app with android studio
Creating the first app with android studioCreating the first app with android studio
Creating the first app with android studio
 
Android For Java Developers
Android For Java DevelopersAndroid For Java Developers
Android For Java Developers
 
Installing eclipse & sdk
Installing eclipse & sdkInstalling eclipse & sdk
Installing eclipse & sdk
 
Android interview questions and answers
Android interview questions and answersAndroid interview questions and answers
Android interview questions and answers
 
Android - Getting started with Android
Android - Getting started with Android Android - Getting started with Android
Android - Getting started with Android
 
Andriod
Andriod Andriod
Andriod
 

Recently uploaded

(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)oannq
 
南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证kbdhl05e
 
西伦敦大学毕业证学位证成绩单-怎么样做
西伦敦大学毕业证学位证成绩单-怎么样做西伦敦大学毕业证学位证成绩单-怎么样做
西伦敦大学毕业证学位证成绩单-怎么样做j5bzwet6
 
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 AvilableCall Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilabledollysharma2066
 
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ EscortsDelhi Escorts Service
 
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan
 
E J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxE J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxJackieSparrow3
 
Inspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxInspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxShubham Rawat
 

Recently uploaded (9)

(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)(南达科他州立大学毕业证学位证成绩单-永久存档)
(南达科他州立大学毕业证学位证成绩单-永久存档)
 
南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证南新罕布什尔大学毕业证学位证成绩单-学历认证
南新罕布什尔大学毕业证学位证成绩单-学历认证
 
Model Call Girl in Lado Sarai Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Lado Sarai Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Lado Sarai Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Lado Sarai Delhi reach out to us at 🔝9953056974🔝
 
西伦敦大学毕业证学位证成绩单-怎么样做
西伦敦大学毕业证学位证成绩单-怎么样做西伦敦大学毕业证学位证成绩单-怎么样做
西伦敦大学毕业证学位证成绩单-怎么样做
 
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 AvilableCall Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
Call Girls In Karkardooma 83770 87607 Just-Dial Escorts Service 24X7 Avilable
 
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
(No.1)↠Young Call Girls in Sikanderpur (Gurgaon) ꧁❤ 9711911712 ❤꧂ Escorts
 
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
Authentic No 1 Amil Baba In Pakistan Amil Baba In Faisalabad Amil Baba In Kar...
 
E J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptxE J Waggoner against Kellogg's Pantheism 8.pptx
E J Waggoner against Kellogg's Pantheism 8.pptx
 
Inspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptxInspiring Through Words Power of Inspiration.pptx
Inspiring Through Words Power of Inspiration.pptx
 

Android basics

  • 1. Android Programming Workshop in University College Ghent Ismo Harjunmaa
  • 2. Content of the Workshop: 1. How android programming differs from plain Java programming 2. Tools for developers 3. Making Hello World 4. Making simple game 5. Deploying application to Android device 6. Publishing application in Adnroid Marketplace 2 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 3. Folder structure of Android project  .java Source files are in src-folder  R.java resource class in gen-folder  Fonts etc. in assets-folder  Project specific resources res-folder  Graphic files in drawable-folders  Vertical UI layout in layout-folder  User-interface texts, tables, styles and colors in values-folder 3 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 4. Activity-class  The core of your application  All the event handlers are implemented in this class (these classes) 4 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 5. UI layout in XML-file  By default main.xml file is created in folder res/layout  All the User Interface elements are described in XML-file  Root element is the layout and there is eight different ones to pick from 5 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 6. Designing UI layout  UI is designed in Eclipse either in graphical layout view or writing elements with attributes to main.xml  Elements are placed by dragging them from library 6 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 7. Description file AndroidManifest.xml  The most important description file AndroidManifest.xml is created in the root folder of your project  In this file you can specify level of the API, screen resolution support, testing methods, permissions etc.  Eclipse shows the attributes of the file either in plain text or selection fields 7 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 8. Content of the Workshop: 1. How android programming differs from plain Java programming 2. Tools for developers 3. Making Hello World 4. Making simple game 5. Deploying application to Android device 6. Publishing application in Adnroid Marketplace 8 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 9. DDMS (Dalvik Debug Monitor Server)  Perspective in Eclipse that shows all running emulators or device  Inside this perspective is a view where you can emulate incoming call, SMS or GPS-signal  In this perspective you can browse the folder structure of the emulator or device 9 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 10. Android-SDK command-line tools  All of the tools that Eclipse uses are actually in the Android-SDK as command-line tools  One command-line tool is NOT in Eclipse: adb (Android Debug Bridge)  With adb you can list processes, connect to SQLite databases etc. 10 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 11. Tools for developers: LogCat  Developer needs to know bit more what is the state of the application  Under folder android-sdk/platform-tools is the adb command  Adb logcat shows the logs that device has output 11 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 12. Tools for developers: LogCat  In the code you use logs like this: import android.util.Log; private static final String TAG =  HelloWorldActivity.class.getSimpleName(); Log.d(TAG, ”This is DEBUG level msg”); Log.e(TAG, ”This is ERROR level msg”); 12 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 13. Tools for developers: traceview  Writes full log from all events into SD-card  Remember to choose SD-card size when creating the AVD  Application needs permission to write external file  Permissions are given in the applications AndroidManifest.xml -file  After the trace file is commited traceview is the tool to analyze the trace file 13 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 14. Tools for developers: draw9patch  Application windows have frames which consists nine pieces: upper-left corner, top... etc.  So called patch dividing tool is installed with Android SDK  Before using the tool you have to draw button, window or frame in drawing tool like photoshop  Go to Android­sdk/tools folder and open draw9patch 14 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 15. Tools for developers: zipalign  If you are NOT using Eclipses ADT Plug-in, you have to run zipalign tool which compacts the APK-package 15 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 16. Tools for developers: sqlite3  In the android-SDK package there is SQLite3 database ready-to-use public class DatabaseHelper extends SQLiteOpenHelper { private static String DATABASE_NAME = "SensorGame"; private static int DATABASE_VERSION = 3; public DatabaseHelper(Context context, String name,  CursorFactory factory,int version) { super(context, DATABASE_NAME, null,  DATABASE_VERSION); } ... 16 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 17. Content of the Workshop: 1. How android programming differs from plain Java programming 2. Tools for developers 3. Making Hello World 4. Making simple game 5. Deploying application to Android device 6. Publishing application in Adnroid Marketplace 17 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 18. Making Hello World  Open Eclipse  Choose from menu: File > New... > Android Project  Choose Build Target from option list: Android 3.X Android Open Source Project  Open main.xml from folder res/layout  While on Graphical Layout view drag TextView-element on the layout and set text 18 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 19. Media player  Found in package android.media  Can play music or video  Played resources are positioned in res/raw folder  Common methods are available playing: play() pausing: pause() stopping: stop() 19 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 20. Sensors in Android Device  From version 1.6: Light, Proximity, Temperature, Pressure, Gyroscope, Accelerometer, Magnetic field, Orientation  From version 2.3: Gravity, Linear acceleration, Rotation vector, Near Field Communication  Not all of them are in your device  SensorManager is the class which controls the sensors 20 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 21. Making simple game  Create another Android project: File > New... > Android Project  Drag three textViews and three seekBars onto the main.xml  Give names for views and bars like XView, XBar, YView, YBar... so you can reference them  21 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 22. Making simple game  In this example we are using Acceleration sensor  Use the SensorManager to create the acceleration sensor  For using sensor you have to first register the sensor and on leave unregister 22 Ismo Harjunmaa – Workshop Gent 9.2.2012
  • 23. References  Komatinemi, MacLean & Hashimi: Pro Android 3