0% found this document useful (0 votes)
2 views

JFDP - Android App Developement Using Java PPT1

Uploaded by

sreenu_pes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

JFDP - Android App Developement Using Java PPT1

Uploaded by

sreenu_pes
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Basics of Android

What is Android?
It is Linux Based O.S
It is Developed by Open Handset Alliance
Andy Rubin is the founder of Android
HTC launched the first product of Android
G1 was first product
All programs written in Android are basically the core java code.
So for starting the android the pre requisite is to learn the concept of java.
Since java is a pure object oriented(Yes it is coz multiple inheritance can be
achieved)
Now core java works on three main concepts.
Polymorphism,Inheritance,Encapsulation
What is Android??
And its Need??
Android is mobile operating System based on Linux.
A simple and powerful SDK.
No licensing,distribution,or development fees but it is an
open source O.S as it is developed on Linux which is an
open source.
Android first version is 1.1 released in 9th feb 2009
Then cup cake(1.5) in 30 april’09
Now currently KitKat(4.2).
Features include-Storage,connectivity,messaging,Media
players,MultiTasking,MultiTouch capability etc.
Concepts or pre-requisite for Android..
• So What Polymorphism is?
• One name many forms(method overloading static and method
overriding runtime polymorphism)
• What Encapsulation is?
• Encapsulation(wrapping of data –Abstract class)
• Inheritance (Reusability of code)
• Keywords like static(directly call by class name),final(to avoid
overriding).
• Interface-no definition or no constructor their as objects are not
initialized in it.
• Apart These Basics concepts Threading comes into picture but we will
see it later.
Architecture to Understand Android..

Now the Architecture of Android comes into picture..


• First the Layered Architecture of Android
• Libraries
• Dx tools use to convert .class file into .dex file(dalvik file) just like in java we convert .java file into .class file by
Interpretor
• Now this .class file(that contain byte code) should be readable by the machine that is machine understandable
code(binary form),and this is done by JVM that reads byte code.
• Similarly,DVM(Dalvik Virtual Machine) reads the .dex file and convert it into .apk that stored in bin folder(we will
see later about bin).
• DVM has lesser memory consumption so it uses registers.
• Registers are used for saving memory and power.
• There are lots of framework for Android App Development such as Hibernate and Spring also the eclispse on which
now I am going to tell u that how u hav to install and run android app on eclipse.
• SAX parser and DOM parser convert XML to Data file.
• SAX parser takes less memory.
Installation Process..
Install Java(for the JDK)
Download eclipse and start its eclipse.exe file
Add plugins of Android-SDK
Create AVD as a Emulator instance
• Anatomy of Android Apps
src-This is a source file(.java) that contains file lyk hello
world.java.Basically code part is written in it(Dynamically design the
UI).
Button b;//this is jst a reference
b=new Button(this);/*this refers here present context*/
b.setText(“hello”);
b.setOnClickListener(new OnClickListener()
{
public void on click()
{
Toast.makeText(getBaseContext,”hey wats
up”,Toast.LENGTH_SHORT).show();
}
});
gen-contains the R.java.
All resources in your project are automatically compiled
into this class so we can refer to them using this class.

Android library(3.0)-this contain .jar file


assets-This folder contains all the assets used by your
application,such as HTML,databases etc.

bin-contains the apk files that generate after program


executed.
Res-this contains all the resources used in app.
Contains few subfolders such as drawable,layout,values.

AndroidManifest.xml-Manifest file for ur Application.


Here we specified the permissions.
<uses-permission android:name=“android.permission.SEND_SMS”/>
Other features are intent-filters,receivers.
Declaring the activity in the manifest

<manifest ... >


<application ... >
<activity android:name=".ExampleActivity" />
...
</application ... >
...
</manifest >
• Intents..
<activity
android:label=“SecondActivity”
android:name=“.secondActivity”>
<intent-filter>
<action android:name=“SecondActivity”
category
android:name=“android.intent.category.DEFAU
LT”/>
</intent-filter>
</activity>
DEFAULT is needed so that this activity(second activity) can be started by
another activity using the startactivity().

When the button is clicked,we use the startActivity() method to display


secondActivity by creating an instance of Intent class and passing it the
intent filter name of secondActivity(which is packagename.secondActivity).

startActivity(new Intent(this,SecondActivity.class));
Button Clicking Event in XML..
<Button
android:onClick=“onClick”/>
public void onClick(View v)
{
Toast.makeText(getApplicationContext(),”hello”,To
ast.LENGTH_SHORT).show();

}
What is Activity??

Activity is a means by whish user interact with the application.

However activity itself doesn’t have presence on screen.

Instead it has to draw the screen using view(it occupies a rectangular


area on screen responsible for handling events such as button) and the
viewgroup(Radiogroup,WebView,Mapview,DateTime picker etc.)

Activities in the system are managed as an activity stack.Which we have


to use come on top.

How to hide Title for Activity?


requestWindowFeature(Window.FEATURE_NO_TITLE) method.
Activity Life cycle

Eg:CallLog
Methods of Activity Life Cycle..
• On Create()-called when Activity is first Created.Use to create and
instantiate the object that u will be using in app.
• onStart()-called when activity become visible.
onResume()-use to start any services or code that needs to run while
your activity is in foreground.(called when interacting the activity.)
onPause()-use to stop any services or code that doesn’t need to run when
your activity is not in foreground. If an activity has lost focus but is still
visible (that is, a new non-full-sized or transparent activity has focus on
top of your activity), it is paused. A paused activity is completely alive (it
maintains all state and member information and remains attached to the
window manager).
onStop()-called when activity is no longer visible to user.
onDestroy()-use to free up resources before your activity is destroyed.
onRestart()-called when to start again the previous activity.
What are Sevices??
Services-Background Application such as Music
Player and all.
Entry in the Manifest file for services.
<service
android:enabled=“true”
android:name=“.serviceBack”/>
</application>
What are Intents??
Types of intents..

Explicit Intent: Full name of the class is used to start that Activity.It
Requires class name.
Intent i=new Intent(class1.this,secondActivity.class);
startActivity(i);
or can write..
startActivity(new Intent(“package.SecondActivity”));//for different
project

Implicit Intent: Action name is used to start a new App or


Activity.It requires action name.
Intent i=new Intent(secondActivity.class);
Working of Intents..

You might also like