Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk...
Transcript of Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk...
![Page 1: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/1.jpg)
OpenLab session 8. 4. 2016
Android development
Matúš Nemec
Faculty of Informatics, Masaryk University
![Page 2: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/2.jpg)
Outline
• Android Studio installation
• Android fundamentals
• Creating an Android project
• Running your application
• Building a simple user interface
• Starting another activity
2 | OpenLab 8. 4. 2016 – Android
![Page 3: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/3.jpg)
Android Studio installation
• Download & install
• https://developer.android.com/sdk/index.html
• On lab computer
• https://dl.google.com/dl/android/studio/ide-
zips/2.0.0.20/android-studio-ide-143.2739321-
windows.zip
• Use 7-Zip to extract to e.g. D:\Android
3 | OpenLab 8. 4. 2016 – Android
![Page 4: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/4.jpg)
Installation
• Run D:\Android\android-studio\bin\studio64.exe
4 | OpenLab 8. 4. 2016 – Android
![Page 5: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/5.jpg)
• Install the SDK to same path as your Android
Studio for easier cleanup
5 OpenLab 8. 4. 2016 – Android
![Page 6: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/6.jpg)
App components
• Activity - single screen with a user interface
• Service - runs in the background to perform long-
running operations; no user interface
• Content provider - manages a shared set of app
data (file system, SQLite DB, web)
• Broadcast receiver - responds to system-wide
broadcast announcements (intents)
6 | OpenLab 8. 4. 2016 – Android
![Page 7: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/7.jpg)
The Manifest file
• Declaring components
– <activity> <service> <receiver> <provider>
• Declaring component capabilities
– <intent-filter>
• Declaring app requirements
– <uses-sdk android:minSdkVersion="7"
android:targetSdkVersion="19" />
– <uses-feature android:name=
"android.hardware.camera.any“ android:required="true" />
7 | OpenLab 8. 4. 2016 – Android
![Page 8: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/8.jpg)
App resources
• Images
• Layouts
– For different screen sizes and orientations
• Strings
– For localization
• Colors
• …
8 | OpenLab 8. 4. 2016 – Android
![Page 9: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/9.jpg)
Building your first app
• Tutorial based on
developer.android.com/training/basics/firstapp/
9 OpenLab 8. 4. 2016 – Android
![Page 10: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/10.jpg)
New project (My First App)
10 OpenLab 8. 4. 2016 – Android
• Create the project at the same location as IDE
![Page 11: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/11.jpg)
Minimum SDK & Target SDK
11 OpenLab 8. 4. 2016 – Android
![Page 12: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/12.jpg)
• https://developer.android.com/about/dashboards/
12 OpenLab 8. 4. 2016 – Android
![Page 13: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/13.jpg)
Add an activity
13 OpenLab 8. 4. 2016 – Android
![Page 14: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/14.jpg)
Customize the Activity (MyActivity)
14 OpenLab 8. 4. 2016 – Android
![Page 15: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/15.jpg)
Project files
15 OpenLab 8. 4. 2016 – Android
![Page 16: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/16.jpg)
Run the app – real device
• Android 3.2 or older
– Settings > Applications > Development.
• Android 4.0 and newer
– Settings > Developer options
• Note: On Android 4.2 and newer, Developer
options is hidden by default. To make it available,
go to Settings > About phone and tap Build
number seven times. Return to the previous screen
to find Developer options.
16 OpenLab 8. 4. 2016 – Android
![Page 17: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/17.jpg)
Run the app – real device
17 OpenLab 8. 4. 2016 – Android
![Page 18: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/18.jpg)
Run on the Emulator
18 OpenLab 8. 4. 2016 – Android
• Select any device
• Install SDK 23 ARM (no Google APIs)
![Page 19: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/19.jpg)
Continue the tutorial
• Building a Simple User Interface
– https://developer.android.com/training/basics/firstapp/buildi
ng-ui.html
• Starting Another Activity
– https://developer.android.com/training/basics/firstapp/starti
ng-activity.html
19 OpenLab 8. 4. 2016 – Android
![Page 20: Android development - CrocsAndroid development MatúšNemec Faculty of Informatics, Masaryk University. Outline • Android Studio installation • Android fundamentals • Creating](https://reader033.fdocuments.net/reader033/viewer/2022042400/5f0eddfc7e708231d441539e/html5/thumbnails/20.jpg)
More guides
• Practical guides
– https://developer.android.com/training/
• Fundamentals
– https://developer.android.com/guide/
• API reference
– https://developer.android.com/reference/packages.html
20 OpenLab 8. 4. 2016 – Android
Cleanup
• If you are working on a lab computer, please delete
Android Studio, Android SDK and your project