calc app

22
Android App CALCULATOR MUHAMMAD SHAHAB AHMAD R.NO “142” ASAD ULLAH R.NO “168” SECTION „C‟ BS(CS) HONS IBMS THE UNIVERSITY OF AGRICULTURE, PESHAWAR,KP.

Upload: asad-ullah-yousufzai

Post on 09-Jul-2015

44 views

Category:

Software


0 download

DESCRIPTION

Android: Beginner

TRANSCRIPT

Page 1: Calc app

Android App

CALCULATOR

MUHAMMAD SHAHAB AHMAD R.NO

“142”

ASAD ULLAH R.NO “168”

SECTION „C‟ BS(CS) HONS IBMS

THE UNIVERSITY OF AGRICULTURE,

PESHAWAR,KP.

Page 2: Calc app

ANDROID A Java program (such as an

Android application

program) undergoes several

translation steps between

the time you write the

program and the time a

processor runs the program.

One of the reasons is

simple: Instructions that are

convenient for processors to

run are not convenient for

people to write.

JAVA SOURCE CODE:

public static void sum()

{

Int a=3,b=4;

System.out.println(“sum of a

and b”);

System.out.println(a+b);

}

Public static void main(String

arg[]){

Sum();

}

}

ANDROID

Page 3: Calc app

The processors in computers, phones, and other devices don‟t normally follow instructions like the instructions in Source code.

i.e processors don‟t follow Java source code instructions.

Instead, processors follow cryptic (having a secret or hidden meaning) instructions like the ones.

Java Byte code

0 aload_0

1 getfield #19

<com/allmycode/samples/MyA

ctivity/room

Lcom/allmycode/samples/Roo

m;>

4 getfield #47

<com/allmycode/samples/Roo

m/numGuests I>

7 ifne 22 (+15)

10 aload_0

……

……

……

ANDROID

Page 4: Calc app

ANDROID

When we write a Java program, we write source code instructions.

After writing the source code, we run a program (that is, we apply a tool) to the source code. The program is a COMPILER: It translates the source code instructions into Java byte code instructions.

In other words, the compiler translates code that we can write and understand into code that a computer can

Java Byte code

0 aload_0

1 getfield #19

<com/allmycode/samples/MyA

ctivity/room

Lcom/allmycode/samples/Roo

m;>

4 getfield #47

<com/allmycode/samples/Roo

m/numGuests I>

7 ifne 22 (+15)

10 aload_0

……

……

……

Page 5: Calc app

ANDROID

In 2007, Dan Bornstein at

Google created Dalvik

bytecode — another way to

represent instructions for

processors to follow.

Dalvik bytecode is optimized

(best use) for the limited

resources on a phone or a

tablet device.

Dalvik Byte code

.method public

checkVacancy(Landroid/view/

View;)V

.limit registers 4

; parameter[0] : v3

(Landroid/view/View;)

.line 30

iget-object

v0,v2,com/allmycode/samples/

MyActivity.room

Lcom/allmycode/samples/Roo

m;

; v0 :

……

……

……

Page 6: Calc app

CREATING AN ANDROID APP

For Creation of An Android App the requirements

are:

JDK (Java Development Kit)

for JAVA

Android SDK (Software Development Kit)

for ANDROID

An IDE (Integrated Development Environment. A

programming environment meshed into a software

program. It provides a text or code editor, a GUI

builder, a compiler, interpreter and debugger)

Eclipse OR

Android Studio

Page 7: Calc app

When we create an Android app, Eclipse/Android

Studio performs at least two compilations:

One compilation creates Java bytecode from

our Java source files.

The source filenames have the .java extension;

the Java bytecode filenames have the .class

extension.

Another compilation creates Dalvik bytecode

from our Java bytecode files.

Dalvik bytecode file names have the .dex

extension.

ANDROID

Page 8: Calc app

Android app has XML files, java files, and possibly other elements.

Before we install an app on a device.

Eclipse/ Android Studio combines all these elements into a single file — one with the .apk extension

To perform the compilation from source code to Java bytecode, Eclipse uses a program named javac, also known as the Java compiler.

To perform the compilation from Java bytecode to Dalvik code, Eclipse uses a program named dx(known affectionately as “the dx tool”).

To combine all your app‟s files into one .apk file, Eclipse uses a program named apkbuilder.

ANDROID

Page 9: Calc app

Open an

ANDROID STUDIO

Page 10: Calc app

To Start a Project;

Click on File Menu and then select NEW PROJECT

Page 11: Calc app

Name of your

APP

Page 12: Calc app

This Dialog box will let you choose the ICON of

your app

Page 13: Calc app

Choose which type of Activity you want to work

on

Page 14: Calc app

Name your

ACTIVITY

Then Click FINISH

Page 15: Calc app

XML file

contains;

•Design

View (Drag

and Drop)

And

•Text View

(Coding of

the Widgets)

Design

View

Page 16: Calc app

XML file

contains;

•Design

View (Drag

and Drop)

And

•Text View

(Coding of

the Widgets)

TEXT

View

Page 17: Calc app

Java File.

Here is the

actual

coding of the

working of

the app

Page 18: Calc app

To RUN your

app, start the

AVD

Manager

By Clicking

On The

ICON

Page 19: Calc app

Click on the

available

AVD,

And then

click START

Page 20: Calc app

The EMULATOR is Starting

Page 21: Calc app

The

EMULATOR

Page 22: Calc app

By Clicking on RUN Button. The APP is running

now!