ISAC – Android programming

22
INTERNATIONAL SUMMER ACADEMIC COURSE UNIVESITY OF NIS ISAC – Android programming

description

ISAC – Android programming. International summer academic course U nivesity of nis. ISAC – Android programming. Introductions into Android programming SDK (Sowtware developement kit) DVM(Dalvik Virtual Machine) JAVA API Eclipse Android App Fundamentals - PowerPoint PPT Presentation

Transcript of ISAC – Android programming

Page 1: ISAC – Android programming

INTERNATIONAL SUMMER ACADEMIC COURSE

UNIVESITY OF NIS

ISAC – Android programming

Page 2: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

ISAC – Android programming

What is an activity?LayoutsManifestXMLR class

Page 8: ISAC – Android programming

ISAC – Android programming

Activity

The basis of android applicationsA single Activity defines a single viewable screen

the actions, not the layoutCan 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: ISAC – Android programming

ISAC – Android programming

Life cycle of an activity

Page 10: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

ISAC – Android programming

1. Intents and intent filter1.1. What are intents?

1.2. Starting activities

Page 17: ISAC – Android programming

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: ISAC – Android programming

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: ISAC – Android programming

3. Data transfer between activities 3.1. Data transfer to the target

componentBundle 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: ISAC – Android programming

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: ISAC – Android programming

3.3. Retrieving result data from a sub-activity

Page 22: ISAC – Android programming