eng. wafaa audah

11
1 Islamic University of Gaza Faculty of Engineering Computer Engineering Department Mobile Computing ECOM 5341 By Eng. Wafaa Audah July 2013

Upload: others

Post on 14-May-2022

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Eng. Wafaa Audah

1

Islamic University of Gaza

Faculty of Engineering

Computer Engineering Department

Mobile Computing ECOM 5341

By

Eng. Wafaa Audah

July 2013

Page 2: Eng. Wafaa Audah

2

Creating Applications and

Activities

Aapplication creation steps and settings

Fill:

Application and

Package Names

>> Next

Page 3: Eng. Wafaa Audah

3

This frame gives

you different

features and

choices for

launcher icon

Page 4: Eng. Wafaa Audah

4

Complete “Hello World” application is created successfully!

Fill:

Activity Name

>> Finish

Page 5: Eng. Wafaa Audah

5

Project structure

src

User specified java source code files will be available here.

gen

Contains auto generated files.

R.java : generated class which contains references to certain

resources of the project.

res

Android supports resources like images and certain XML

configuration files. This res folder will be having sub-folders

to keep the resources based on its type.

/res/values

Used to define strings, colors, dimensions, styles and static

arrays of strings or integers. By convention each type is

stored in a separate file, e.g. strings are defined in the

res/values/strings.xml file.

/res/values-v11 is the values of the API version 11.

/res/values-v14 is the values of the API version 14

/res/layout

This folder contains the layouts to be used in the application.

A layout resource defines the architecture for the UI in an

Activity or a component of a UI.

Page 6: Eng. Wafaa Audah

6

/res/menu

This folder contains menu resources to be used in the application (Options Menu,

Context Menu, or submenu)

/res/drawable

Drawable folders are resource directories in an application that provides different

bitmap drawables for medium, high, and extra high density screens.

/res/drawable-mdpi - bitmap for medium density

/res/drawable-hdpi - bitmap for high density

/res/drawable-xhdpi - bitmap for extra high density

/res/drawable-nodpi - bitmap with no pre-scaling

libs

External library files will be placed in this folder.

assets

This folder contains unstructured raw hierarchy of files and directories, with no other

capabilities.

bin

This Folder is the area used by the compiler to prepare the files to be finally packaged

to the application’s APK file. This includes

- Compiling your Java code into class files

- Putting your resources (including images) into a structure to be zipped into the

APK

Page 7: Eng. Wafaa Audah

7

Anatomy of Android Applications

An Android application consists of one or more core components:

1. Activity

2. Service

3. Broadcast receiver

4. Content provider

Activity

• A typical Android application consists of one or more activities.

• Activity is a single screen with a user interface

• An activity usually shows a single visual user interface (UI).

• Only one activity is chosen to be executed first when the application is launched.

• An activity may transfer control and data to another activity through an interprocess

communication protocol called intents.

An activity should have a java class that extends the activity class and an .XML file

to define the interface.

AndroidManifest.xml

This file contains essential information about the application to the Android system,

information the system must have before it can run any of the application's code.

(control general application configuration)

ic_launcher-web.png

This is an icon to be used in Google play. Applications on Google Play require a high

fidelity version of the application icon.

project.properties

Is the main project’s properties file containing information such as the build

platform target. It holds various settings for the build system, updated by the ADT.

Page 8: Eng. Wafaa Audah

8

Activity

setContentView(R.layout.activity_first) used to connect the activity code

(FirstActivity)to its XML interface (activity_first)

Graphical Layout

Page 9: Eng. Wafaa Audah

9

AndroidManifest.xml

The <intent-filter> declares that this activity is the entry point

(android.intent.action.MAIN) of the application. This activity is to be added to the

application launcher (android.intent.category.LAUNCHER).

Add activity to AndroidManifest.xml

Every time you create new activity, you must add it to the manifest file

Application tab >> Add >> Activity >> Ok*** Browse >> “name of your activity” >> ok

Page 10: Eng. Wafaa Audah

10

Lab Work

Create new activity (new class), create new Android xml layout file

and bind them together.

Add a toast to the new activity by the following line:

Toast.makeText(getApplicationContext(), "welcome at the second activity", Toast.LENGTH_SHORT).show();

[Toast will be like this]

Add new activity to the AndroidManifest.xml file.

Bind two activities (default, new) using the following method:

startActivity(new Intent(currentActivity.this,secondActivity.class));

[This method switch between two activities]

Intent details and uses will be shown later ……….

Page 11: Eng. Wafaa Audah

11

If you want to create new activity you can

1. Choose class >> then you must add it to the manifest and bind the code with

layout

2. Choose other >> android activity: all configurations will be done.

According to project structure …. Resources folder and its subfolders …..

SEE YOU AT THE NEXT LAB

Homework

Change “Hello World” text into “This is lab 1” and change its

background color into red.

(With/without using code)

Change your application icon.

Change foreground text language to Arabic.

(For example, Hello World will be مرحبا أيها العالم(

(In order to change language: Settings >> Language & Input >>

language >> العربية

Report must include lab work + homework.