Advance Android application development workshop day 4

11

description

10 Days Android Workshop at L J Institute of engineering and technology delivered by Cresco Solution visit: http://www.crescosolution.com/android-workshop-at-l-j-institute-of-engineering-and-technology-ahmedabad/

Transcript of Advance Android application development workshop day 4

Page 1: Advance Android application development workshop day 4
Page 2: Advance Android application development workshop day 4

www.crescosolution.com

Intent

Allow you to interact with

components from the own and other

applications

Page 3: Advance Android application development workshop day 4

www.crescosolution.com

Types of Intent

• Explicit

• Implicit Intent

• An application can define the target component directly in the intent Explicit

• Ask the Android system to evaluate registered components based on the intent data implicit intents

Implicit

Page 4: Advance Android application development workshop day 4

www.crescosolution.com

Explicit Intent

Explicit Intent

The component which should be called by the Android system, by using the Java class as identifier , The following shows how to create an explicit intents and send it to the Android system

Typically used within an application as the classes in an application are controlled by the application developer

i.e :- Intent i = new Intent (This, SecondActivity.class);

startActivity(i);

Page 5: Advance Android application development workshop day 4

www.crescosolution.com

Implicit Intent

Implicit intents specify the action which should

be performed and optionally data which provides data for the action , For example

the following tells the Android system to view a webpage. All installed

web browsers should be registered to the corresponding intent

data

Page 6: Advance Android application development workshop day 4

www.crescosolution.com

Data transfer between activities using INTENT

An intent contains the action and optionally additional data

The component which creates the Intent can add data to it via the overloaded putExtra() method

Extras are key/value pairs; the key is always a String

This Intent object can be retrieved via the getIntent() method

The component which receives the intent can use the getIntent().getExtras() method call to get the extra data

i.e :- Bundle extras = getIntent().getExtras();

if (extras == null) {return;}// Get

data via the keyString value1 = extras.getString(Intent.EXTRA_TEXT);if (value1 != null) { // do something with the data}

Page 7: Advance Android application development workshop day 4

www.crescosolution.com

Android MANIFEST

Every application must have an AndroidManifest.xml file (with precisely that name) in its root directory

Manifest file for an android application is a resource file which contains all the details needed by the android system about the application

It is a key file that works as a bridge between the android developer and the android platform

It helps the developer to pass on functionality and requirements of our application to Android

This is an xml file which must be named as AndroidManifest.xml and placed at application root.

Page 8: Advance Android application development workshop day 4

www.crescosolution.com

Elements for application components

The set of attributes based on user interface

Specifies target activities

The operation provided by any library or API, running in background that is not visible

That makes to receive message broadcasted by the same application or by outside entity

Provides some structure to access application data

It specifies set of library files need to run the application

Page 9: Advance Android application development workshop day 4

www.crescosolution.com

Structure of Android Manifest.xml

<manifest><Elements for Application properties should come here -refer above for list><application><Elements for application components should come here -

refer above for list></application></manifest>

Page 10: Advance Android application development workshop day 4

www.crescosolution.com

Sample AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="com.example.android"android:versionCode="1"android:versionName="1.0" > <uses-sdk android:minSdkVersion="7" /> <application

android:icon="@drawable/ic_launcher"android:label="@string/app_name" ><activity

android:label="@string/app_name"android:name=".HelloWorld" ><intent-filter >

<action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" />

</intent-filter></activity></application> </manifest>

Page 11: Advance Android application development workshop day 4