android session 3-behestee

Post on 18-Nov-2014

133 Views

Category:

Education

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Android Training session at Jaxara IT

TRANSCRIPT

ANDROID TRAININGSESSION – 3

-Hussain KMR Behestee

AGENDAS

• Intents – Explicit Intents– Implicit intents

• Broadcast Receivers• Notifications & Toasts

EXPLICIT INTENTS

• We saw some Explicit Intents in previous session.

• Today we will see few more, like as– Start another activity– Start another activity with sending data– Start another activity for getting result

START ANOTHER ACTIVITY

• Start another activity

• Start another activity with sending data

• Receive data

START ANOTHER ACTIVITY FOR GETTING RESULT

• Start activity to get result

• Callback

START ANOTHER ACTIVITY FOR GETTING RESULT

• Send back to caller activity

• Please see here for details.

IMPLICIT INTENT

• Implicit intent are those which intents have no specific activity to show. We will learn here-– Call other app to share your content– Allow other apps to start your activity– Call other app to do a task– Caution

CALL OTHER APP TO SHARE YOUR CONTENT

• Initiating call-

• This will show all applications which are registered for this type.

• To get registered to response youhave allow them.

ALLOW OTHER APP TO START YOUR ACTIVITY

• Add Intent Filter to manifest

• Add mime type as much you want to register.

EXTRA

• Install apps to simulator– adb install <file>

IMPLICIT INTENT: CAUTION• Caution: If you invoke an intent and there is no app available on the

device that can handle the intent, your app will crash.• To verify there is an activity available that can respond to the intent, call

queryIntentActivities() to get a list of activities capable of handling your Intent. If the returned List is not empty, you can safely use the intent. For example:

• Please see details at here.

CALL OTHER APP TO SHARE YOUR CONTENT

• Safe call with create chooser

BROADCAST RECEIVERS

• A broadcast receiver is a component that responds to system-wide Broadcast announcements.

• Many broadcasts originate from the system– For example, a Broadcast announcing that the

screen has turned off, the battery is low, or a picture was captured or an SMS is received.

BROADCAST RECEIVERS

• Applications can also initiate broadcasts—for example, to let other applications know that some data has been downloaded to the device and is available for them to use.

• Although broadcast receivers don't display a user interface, they may create a status bar notification to alert the user when a broadcast event occurs.

BROADCAST RECEIVERS

• To receive a broadcast when SMS received

BROADCAST RECEIVERS

• In manifest

NOTIFICATION

• Toast Display– Toast.makeText(context, str,Toast.LENGTH_LONG).show();

• Notification drawer– On Next Session ;-)

QUESTION?

?

THANK YOU

top related