Download presentation
Presentation is loading. Please wait.
Published byFerdinand Turner Modified over 9 years ago
1
Intent Android Club 2015
2
Agenda Intent class Explicit activation Implicit activation
3
2 purposes Operation to be performed (Send email) Event notification (Telegram message came)
4
I want to... Select contact Take photo Display map
5
Intent opens... Activity which can do that operation
6
Intent fields Action – desired operation Data – data associated with intent Category – additional information Type – show mime type Component – exact activity to open Extras – key-value pair Flags – flag about how intent handled
7
Action ACTION_DIAL ACTION_VIEW ACTION_SEND ACTION_MAIN
8
Action: example Intent intent = new Intent(); intent.setAction(Intent.ACTION_DIAL); startActivity(intent);
9
Data Data associated with intent URI(geo, tel, http)
10
Data: example Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("geo:0.0,0.0")); startActivity(intent);
11
Data: practice Create application which opens Tashkent in Google Maps Latitude: 41.2667 Longitude: 69.2167
12
Data: example 2 Intent intent = new Intent(); intent.setAction(Intent.ACTION_DIAL); Intent.setData(Uri.parse(“tel:+9989037351 73”); startActivity(intent);
13
Data: practice 2 Create application which dials your best friends number
14
Data: example 3 Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse("http://google.co m")); startActivity(intent);
15
Data: practice 3 Create application which opens Facebook website
16
Category Additional information about Intent CATEGORY_BROWSABLE CATEGORY_LAUNCHER
17
Type Specifies MIME type of Intent image/png, image/jpg text/html, text/html setType() emailIntent.setType("text/html");
18
Type: example final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEN D); emailIntent.setType("text/html"); emailIntent.putExtra(android.content.Intent. EXTRA_SUBJECT, subject); startActivity(intent);
19
Component Intent intent = new Intent(MainActivity.this, ActivityB.class); startActivity(intent);
20
Component: practice Create ActivityA Create ActivityB Put button on ActivityA which opens ActivityB
21
Extra Key-value pair Intent intent = new Intent(A.this, B.class); intent.putExtra(“parol”,”1234”); startActivity(intent);
22
Extra: practice Create ActivityA Create ActivityB Put button which sends “secret information” to ActivityB Secret information: We are members of Android Club Show secret information in ActivityB
23
Flags How intent should be handled FLAG_ACTIVITY_NO_HISTORY FLAG_ACTIVITY_NO_ANIMATION
24
Flags: example Intent intent = new Intent(MainActivity.this, ActivityB.class); intent.setFlags(Intent.FLAG_ACTIVITY_CL EAR_TASK|Intent.FLAG_ACTIVITY_NEW _TASK); startActivity(intent);
25
Flags: practice Create ActivityA Create ActivityB Create ActivityC Put button on A which opens B Put button on B which opens C and close A and C
26
Activation Explicit (Явный) Implicit (Неявный)
27
Implicit activation A) Calling activity B) IntentFilter
28
Intent resolution ACTION DATA CATEGORY
29
Homework 1: extra Create ActivityA Create ActivityB Put 2 EditTexts: username and password Pass username and password to ActivityB Show them in TextViews
30
Homework2: flag Create ActivityA Create ActivityB Open ActivityB without animation
31
Homework3: implicit activation Create ActivityA From ActivityA, startActivity with ACTION_DIAL intent Create ActivityB Define for ActivityB
32
Homework4: implicit activation Create ActivityA From ActivityA, startActivity with EMAIL_APP(category) intent Create ActivityB Define for ActivityB
33
Homework: Action+Data: Try to put ACTION_CALL instead of ACTION_DIAL Tell me what is difference? Do not forget to add android.permission.CALL_PHONE
34
Questions? Any questions?
35
Thank you Thank you for your attention!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.