Vous êtes sur la page 1sur 25

ANDROID APPLICATION DEVOLEPMENT

ANDROID APPLICATION DEVOLEPMENT


TOPICS I N T R O D U C T I O N L A Y E R S I N A N D R O I D D A L V I K V M X M L S Q L L I T E V I E W S C O N T E N T P R O V I D E R R E S O U R C E M A N A G E R A C T I V I T Y M A N A G E R N O T I F I C A T I O N M A N A G E R

INTRODUCTION
Android is a Linux-based operating system for mobile devices such as smartphones and tablet computers. It is developed by the Open Handset Alliance, led by Google, and other companies.

RELATED INFORMATIOS

LAYERS ON ANDROID OS

THE RED LAYER


The red layer represents the services offered by the Linux kernel and associated GNU utility packages ported to the ARM architecture

THE GREEN LAYER


The green layer consists entirely of open source libraries available under various licenses. any phone that would customize the libraries found in this layer, add libraries or remove them altogether would no longer be able to brand itself as an Android phone.

THE BLUE LAYER


the application developer has access to what Android refers to as service processes. These services are invisible to the user of the handset. Application developers can communicate with these services via a message bus.

DALVIK VIRTUAL MACHINE


Dalvik is the process virtual machine (VM) in Google's Android operating system.
Programs are commonly written in a dialect of Java and compiled to bytecode. Then they are converted from Java Virtual Machinecompatible .class files to Dalvik-compatible .dex
The compact Dalvik Executable format is designed to be suitable for systems that are constrained in terms of memory and processor speed.

A tool called dx is used to convert some (but not all) Java .class files into the .dex format.

It is the software that runs the apps on Android devices

originally written by Dan Bornstein

FUNCTION OF XML

Layout
String storage Shared preferences

Define Buttons and Text fields Calling that layout on run time

All strings for that application can be stored in an xml file String ID are called to with @ symbol to get the string value Retained values can be stored in xml files Using inbuilt functions we can fetch the data from that xml file using the ID

USING XML IN ANDROID(layout)


<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <TextView android:id="@+id/text" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a TextView" /> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello, I am a Button" /> </LinearLayout>

USING XML IN ANDROID(layout)


public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState); setContentView(R.layout.main_layout);
}

USING XML IN ANDROID(string storage)

String.xml file in the android project is the space for string storage

USING XML IN ANDROID(shared pref)

public class Calc extends Activity { public static final String PREFS_NAME = "MyPrefsFile";

@Override protected void onCreate(Bundle state){ super.onCreate(state); ...


// Restore preferences SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); boolean silent = settings.getBoolean("silentMode", false); setSilent(silent);

@Override protected void onStop(){ super.onStop(); // We need an Editor object to make preference changes. // All objects are from android.context.Context SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("silentMode", mSilentMode); // Commit the edits! editor.commit();

SQLITE

Android provides full support for SQLite databases.

The recommended method to create a new SQLite database is to create a subclass of SQLiteOpenHelper

override the onCreate() method, in which you can execute a SQLite command to create tables in the database.

SQLITE(EXAMPLE)
public class ContactOpenHelper extends SQLiteOpenHelper {

private static final int DATABASE_VERSION = 2; private static final String _TABLE_CONTACTS = contact"; private static final String TABLE_CREATE = "CREATE TABLE " + TABLE_CONTACT + " (" + KEY_ID + " TEXT, " + KEY_NAME + " TEXT KEY_PH_NO + " TEXT);";
ContactOpenHelper(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); }

@Override public void onCreate(SQLiteDatabase db) { db.execSQL(DICTIONARY_TABLE_CREATE); }

SQLITE(INSERT)
ContentValues values = new ContentValues(); values.put(KEY_NAME, contact.getName()); values.put(KEY_PH_NO, contact.getPhoneNu()); sql = "INSERT INTO table1 (field1, field2, field3) " + "VALUES (" + KEY_ID+ ", " + KEY_NAME +,+KEY_PH_NO+ ")"; Log.v("Test Saving", sql); myDataBase.rawQuery(sql, null);

db.insert(TABLE_CONT ACTS, null, values); db.close();

SQLITE(READ)
public Contact getContact(int id) { SQLiteDatabase db = this.getReadableDatabase(); Cursor cursor = db.query(TABLE_CONTACTS, new String[] { KEY_ID, KEY_NAME, KEY_PH_NO }, KEY_ID + "=?", new String[] { String.valueOf(id) }, null, null, null,

null); if (cursor != null) cursor.moveToFirst();


Contact contact = new Contact(Integer.parseInt(cursor.getString(0)), cursor.getString(1), cursor.getString(2)); // return contact return contact; }

LAYOUTS

LAYOUTS
LINEAR FRAME TABLE RELATIVE

CONTENT PROVIDERS
Enable use to get the data from other process too

Getting the data from the phone applications like sms ,log,contact etc are being handled by content providers

Secure data transmission is being promised

RESOURCE MANAGER

Different resources are being required by defferent devices

Setting that resources is bing done by resource manager

Once an application is being created it works on all cofiguration of phones with same android os version

Enable to increase the speed and memeory usage of the application

NOTIFICATION MANAGER

Alerting the user by flashing the backlight, playing a sound, or vibrating

Turning on or flashing LEDs on the device

A persistent icon that goes in the status bar and is accessible through the launcher, (when the user selects it, a designated Intent can be launched),

ACTIVITY MANAGER

Activity life cycle

Retaining the activity state

Checking for permissions

Configuration changes

Hands on Exercise

Step 1:Hello world Application Step 2:Set a toast/notification Step3:Send sms Step4:Set notification for receive sms Step5:Sms notification application is being made

Doubts and Queries

Vous aimerez peut-être aussi