Top Banner
ANDROID TRAINING SESSION – 3 -Hussain KMR Behestee
19

Android session 3-behestee

Nov 18, 2014

Download

Education

Android Training session at Jaxara IT
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Android session 3-behestee

ANDROID TRAININGSESSION – 3

-Hussain KMR Behestee

Page 2: Android session 3-behestee

AGENDAS

• Intents – Explicit Intents– Implicit intents

• Broadcast Receivers• Notifications & Toasts

Page 3: Android session 3-behestee

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

Page 4: Android session 3-behestee

START ANOTHER ACTIVITY

• Start another activity

• Start another activity with sending data

• Receive data

Page 5: Android session 3-behestee

START ANOTHER ACTIVITY FOR GETTING RESULT

• Start activity to get result

• Callback

Page 6: Android session 3-behestee

START ANOTHER ACTIVITY FOR GETTING RESULT

• Send back to caller activity

• Please see here for details.

Page 7: Android session 3-behestee

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

Page 8: Android session 3-behestee

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.

Page 9: Android session 3-behestee

ALLOW OTHER APP TO START YOUR ACTIVITY

• Add Intent Filter to manifest

• Add mime type as much you want to register.

Page 10: Android session 3-behestee

EXTRA

• Install apps to simulator– adb install <file>

Page 11: Android session 3-behestee

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.

Page 12: Android session 3-behestee

CALL OTHER APP TO SHARE YOUR CONTENT

• Safe call with create chooser

Page 13: Android session 3-behestee

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.

Page 14: Android session 3-behestee

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.

Page 15: Android session 3-behestee

BROADCAST RECEIVERS

• To receive a broadcast when SMS received

Page 16: Android session 3-behestee

BROADCAST RECEIVERS

• In manifest

Page 17: Android session 3-behestee

NOTIFICATION

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

• Notification drawer– On Next Session ;-)

Page 18: Android session 3-behestee

QUESTION?

?

Page 19: Android session 3-behestee

THANK YOU