international summer academic course univesity of nis isac – android programming
TRANSCRIPT
![Page 1: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/1.jpg)
INTERNATIONAL SUMMER ACADEMIC COURSE
UNIVESITY OF NIS
ISAC – Android programming
![Page 2: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/2.jpg)
ISAC – Android programming
Introductions into Android programming• SDK (Sowtware developement kit)• DVM(Dalvik Virtual Machine)• JAVA API• Eclipse
Android App Fundamentals The process of creating an android application Android SDK configuration Creating a new virtual device
![Page 3: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/3.jpg)
ISAC – Android programming
Setup
Set up your developement environment
Set up AVDs and devices for testing
Install the Android SDK, Android Developement Tools and Android platforms
Create Android Virtual Devices and connect hardware devices for testing
Developement Create your application
Create an Android project with your source code, resources and manifest file
![Page 4: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/4.jpg)
ISAC – Android programming
Debugging and testing
Build and run your application
Debugg your application
Build and run your application in debug mode
Debug your application using the Android debugging and logging tools
Test your application
Test your application using emulator or real devices
![Page 5: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/5.jpg)
ISAC – Android programming
Publishing
Prepare your application for release
Debugg your application
Configure, build and test your application in release mode
Publicize, sell and distribute your application to users
![Page 6: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/6.jpg)
Android SDK Configuring Android SDK manager Creating virtual devices Getting to know the environment Creating a new Android project and a “Hello world”
application
ISAC – Android programming
![Page 7: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/7.jpg)
ISAC – Android programming
What is an activity?LayoutsManifestXMLR class
![Page 8: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/8.jpg)
ISAC – Android programming
Activity
The basis of android applicationsA single Activity defines a single viewable
screen the actions, not the layout
Can have multiple per applicationEach is a separate entityThey have a structured life cycle
Different events in their life happen either via the user touching buttons or programmatically
![Page 9: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/9.jpg)
ISAC – Android programming
Life cycle of an activity
![Page 10: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/10.jpg)
ISAC – Android programming
Project components
src – your source codegen – auto-generated code (usually just R.java)Included librariesResources
Drawables (like .png images) Layouts Values (like strings)
Manifest file
![Page 11: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/11.jpg)
ISAC – Android programming
XML – Extensible Markup Language
Used to define some of the resources Layouts (UI) Strings
Manifest file Shouldn’t usually have to edit it directly, Eclipse can do that for you Preferred way of creating UIs
Separates the description of the layout from any actual code that controls it
Can easily take a UI from one platform to another
![Page 12: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/12.jpg)
ISAC – Android programming
R class
Auto-generated: you shouldn’t edit itContains IDs of the project resourcesEnforces good software engineeringUse findViewById and Resources object to get
access to the resources Ex. Button b = (Button)findViewById(R.id.button1) Ex. getResources().getString(R.string.hello));
![Page 13: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/13.jpg)
ISAC – Android programming
Mafinest file
Contains characteristics about your application When have more than one Activity in app, NEED to specify it in
manifest file Go to graphical view of the manifest file Add an Activity in the bottom right Browse for the name of the activity
Need to specify Services and other components too Also important to define permissions and external libraries, like
Google Maps API
![Page 14: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/14.jpg)
ISAC – Android programming
UI, layouts and components used in Android apps
Layouts
Eclipse has a great UI creator Generates the XML for you
Composed of View objectsCan be specified for portrait and landscape mode
Use same file name, so can make completely different UIs for the orientations without modifying any code
Types of layouts: Linear, Relative, Frame...
![Page 15: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/15.jpg)
ISAC – Android programming
UI, layouts and components used in Android apps
Layouts
Eclipse has a great UI creator Generates the XML for you
Composed of View objectsCan be specified for portrait and landscape mode
Use same file name, so can make completely different UIs for the orientations without modifying any code
Types of layouts: Linear, Relative, Frame...
![Page 16: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/16.jpg)
ISAC – Android programming
1. Intents and intent filter1.1. What are intents?
1.2. Starting activities
![Page 17: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/17.jpg)
ISAC – Android programming
The following code demonstrates how you can start
another activity via an intent.
# Start the activity connect to the # specified class
Intent i = new Intent(this, ActivityTwo.class); startActivity(i);
![Page 18: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/18.jpg)
2. Intents types2.1. Different types of intents2.2. Explicit IntentsExplicit intents explicitly define the component which
should be called by the Android system, by using the Java class as identifier.
2.3. Implicit IntentsImplicit intents specify the action which should be
performed and optionally data which provides content for the action.
![Page 19: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/19.jpg)
3. Data transfer between activities 3.1. Data transfer to the target
component
Bundle extras = getIntent().getExtras(); if (extras == null) { return; } // get data via the key String value1 = extras.getString(Intent.EXTRA_TEXT); if (value1 != null) { // do something with the data }
![Page 20: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/20.jpg)
3.2. Example: Using the share intent
// this runs, for example, after a button clickIntent intent = new Intent(Intent.ACTION_SEND);intent.setType("text/plain"); intent.putExtra(android.content.Intent.EXTRA_TEXT, "News for you!"); startActivity(intent);
![Page 21: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/21.jpg)
3.3. Retrieving result data from a sub-activity
![Page 22: INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming](https://reader030.vdocuments.net/reader030/viewer/2022033104/56649dbb5503460f94aac09e/html5/thumbnails/22.jpg)