+ All Categories
Home > Education > Level 1 & 2

Level 1 & 2

Date post: 18-Jan-2017
Category:
Upload: skumartarget
View: 100 times
Download: 0 times
Share this document with a friend
30
INTENTS
Transcript
Page 1: Level 1 & 2

INTENTS

Page 2: Level 1 & 2

CONFIDENTIAL INFORMATIONThis document is confidential and proprietary information of Target Soft Systems. Confidential Information includes, but is not limited to, the following: Corporate, Employee and Infrastructure Information about Target Soft Systems.

Target Soft Systems implementation , Training methodology, cost, project management and quality processes. Any disclosure of Confidential Information to, or use of it by a third party (i.e., a party other than authorised , will be damaging to Target Soft Systems). Ownership of all Confidential Information, no matter in what media it resides, remains with Target Soft Systems( TSS ). Confidential Information in this document shall not be disclosed outside the buyer’s proposal evaluators and shall not be duplicated, used, or disclosed – in whole or in part – for any purpose other than to evaluate this proposal without specific written permission of an authorized representative of Target Soft Systems.

Page 3: Level 1 & 2

Three of the core components of an Android application -

activities, services, and broadcast receivers - are activated

through messages, called intents

One activity starts another activity by creating/sending an

Intent

Page 4: Level 1 & 2

Types of Intents

Implicit intents

Do not name a target (the component name field is blank).

Implicit intents are often used to activate components in other

applications.

Syntax for Implicit Intent:// Implicit Intent by specifying a URI Intent i = new Intent(android.content.Intent.ACTION_VIEW,

uri.parse("http://www.example.com"));// Starts Implicit Activity startActivity(i);

Page 5: Level 1 & 2

Explicit intents

Designate the target component by its class (the component

name field is set by the class name)

Page 6: Level 1 & 2

Syntax for Explicit Intent:

// Explicit Intent by specifying its class name Intent i = new Intent(Currentactivity.this, TargetActivity.class);

i.putExtra("Key1", "ABC");

i.putExtra("Key2", "123");

// Starts TargetActivity

startActivity(i);

Page 7: Level 1 & 2

Value Passing using IntentWe can pass the values by using Intent and Bundle.Value passing by intent:

We can pass values from activity to another activity using Intent.Syntax:

Intent i = new (context, destination.class);// we can put the values using “putExtra” method

i.putExtra(“key1”,”Target”);startActivity(i);

//We can get the value in other activity using below syntaxgetIntent().getCharSequenceExtra (“key1”).toString();

Page 8: Level 1 & 2

Value passing by Bundle:We can also pass values from activity to another

activity using Bundle.

Syntax:Intent i = new (context, destination.class);Bundle b = new Bundle();b.putCharSequence(“key1”,”android”);i.putExtra(b);startActivity(i);

//We can get the value in other activity using below syntax getIntent().getExtra().getCharSequenceExtra(“key1”).toString();

Page 9: Level 1 & 2

Alert Dialog

Page 10: Level 1 & 2

• An AlertDialog is an extension of the Dialog class.

• It should be used for dialogs that use any of the following features:– A title– A text message– One, two, or three buttons– A list of selectable items (with optional checkboxes or radio

buttons)• To create an AlertDialog, use the AlertDialog.Builder subclass. • Get a Builder with AlertDialog.Builder(Context) and then use the

class's public methods to define all of the AlertDialog properties.• After you're done with the Builder, retrieve the AlertDialog object

with create().

Page 11: Level 1 & 2
Page 12: Level 1 & 2

View Groups

A ViewGroup provided a layout in which the order and appearance of

the views are placed.

A view derives from the base class android.view.ViewGroup.

Android supports the following ViewGroups,

LinearLayout RelativeLayout

AbsoluteLayout TableLayout

FrameLayout ScrollView

Page 13: Level 1 & 2

Linear LayoutArranges views in a single column

or single row.

Page 14: Level 1 & 2

Absolute LayoutEnables to specify the exact location of its

children.

Page 15: Level 1 & 2

Table Layout

Groups views into rows and columns.

Page 16: Level 1 & 2

Relative Layout

Enables us to specify how child views are positioned relative to each other.

Page 17: Level 1 & 2

MENU CONCEPTS WITH XML ATTRIBUTE

Page 18: Level 1 & 2

• Types of application menus:

Options Menu

The options menu is the primary collection of menu

items for an activity. It's where you should place actions that

have a global impact on the app, such as "Search," "Compose

email," and "Settings.“

Context Menu

A floating list of menu items that appears when

the user touches and holds a view that's registered to provide a

context menu.

Menus in Android

Page 19: Level 1 & 2

Plus

Home

Pre

Next

<option menu>

Sub1

Sub2

Hi

Hola

Hello

<sub-menu>

<context menu from EditText>

Long press in EditText

Submenu

A floating list of menu items that appears

when the user touches a menu item that contains a

nested menu.

Page 20: Level 1 & 2

ANDROID ANDROID

COMPONENTSCOMPONENTS

Page 21: Level 1 & 2

ActivityActivity

ServicesServices

BroadcastBroadcast

ReceiverReceiver

ContentContent

ProviderProvider

Page 22: Level 1 & 2

Activities

Visual user interface focused on a single thing a user can do

Services

`No visual interface – they run in the background

Broadcast Receivers

Receive and react to broadcast announcements

Content Providers Allow data exchange between applications

Page 23: Level 1 & 2

Service Life Cycle

Page 24: Level 1 & 2

ServicesNormally Services are two types, they are

1.Synchronous Service

2.Asynchronous Service

Synchronous Service:Service is an application component

representing either an application desire to perform a long-running operations while not interacting with the user or to supply functionality for other application to use.

In synchronous service we are using mainly 6 methods.

Page 25: Level 1 & 2

1. OnCreate()2. OnStartCommand()3. OnBind()4. OnUnbind()5. OnRebind()6. OnDestroy()

Example:

Public void onCreate(){

// TODO Auto-generated method stubsuper.onCreate();

}

Page 26: Level 1 & 2

@Override public int onStartCommand(Intent intent, int flags, int startId) {

// TODO Auto-generated method stub

return super.onStartCommand(intent, flags, startId);

}

@Overridepublic void onDestroy() {

super.onDestroy();

}

Page 27: Level 1 & 2

Asynchronous Service:AsyncTask is a abstract class provided by android

which helps us to use the UI thread proparly.

This class allows us to perform long/background operations and show its result on the UI thread without having to manipulate thread.

In Asynchronous service we are using 4 Steps.

1. OnPreExecute() 2. OnDoInBackground() 3. OnProgressUpdate() 4. OnPostExecute()

Page 28: Level 1 & 2

In AsyncTask we are using only 2 methods, they are1. OnCreate()2.OnStartCommand()Example:protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);

tv = (TextView)findViewById(R.id.textView1Sampleayntask);

new SampleTask().execute();}

Page 29: Level 1 & 2

private class SampleTask extends AsyncTask<Void, Integer, Void>{ @Override protected void onPreExecute() { tv.setText("******** Countdown Starts ********"); }

@Overrideprotected Void doInBackground(Void... params){

return null;}protected void onProgressUpdate(Integer... values)

{tv.setText( Integer.toString(values[0].intValue()));

} @Override protected void onPostExecute(Void result) {

tv.setText("******** DONE ********");

}}

Page 30: Level 1 & 2

THANK YOU


Recommended