Download as pdf
Download as pdf
You are on page 1of 21
3.9 Notifications PART-B ESSAY QUESTIONS WITH soLuTIONS rents [AND BROADCASTS ! W jpcent i | pout intents and its uses. ne ae adel pope O61) Oo e r ‘ at. It can “ ge define a mevoging tes halls ro eet 0 action om the application comPom et sages mechanism that can be implemented within the application and between #PP tion ao 2 ato on nents ar as follows, — ations. i i rng se ia in pin eve He PI tio aie a et of independent ompones a uve inp an intercon : her expliily or implicit » asa : in be wed lsat activities or services, These activites canbe started e 4 et gel iokmdeasteens messages alte component ofthe Applications ne 2) a ore olsen and respond tothe broadest nents “These broadeast intents are used 10 om ich as Intemet connection, battery levels et In android, a ications such as call dialer an bed Se eae received and response Bi need to register Broadcast form about the system" xd messages ven (0 eee which listen to specific broadcast intens like incoming call (oF) mess2Bs Sessaccringy - el sing Intents to Launch ‘Activity - Explicitly Starting New ‘Activity, Implicit Intents, tions 8 passing Data to Intents, Getting Results from Activities, Native Ac junching activities using intents. pt in bref about lat ait a Model Paper, (8) yee - , vies re sed to unchctves that allows creation fa rr for lle ereens. Te activity Gam Be created sepsbcivny meta and posing specie tent 0 the method which is shown below, stanctivty(User_itent) cin ntenste actvtes can Be launched ot) tated eer expicily of implicitly. ply Starting a New Activity For answer refer Unt, Q130). Anpicty Starting a New Activity Focanswer refer Unit, Q13(i) Fi Wite short notes on the following, (Explicitly starting new activity ‘ (i Implicit intent. foower 1 1) Explcly Starting New Activity ‘enealy, applications contain multiple interrelated sere sailed irasiin inbetween then, its necessiy to specify the activity tobe opened. nc avy las can be started exp by ceing ane itn to determine curren activity contest and new Signy pamters Now pss he ew intent statActvity method 3s shown below, Inert in = new ltent(MyActvitysi, MyNewActiviy lass); seca su Bt atv is eae, stared a ‘yen be loved or removed fo stl eed to mavigate ober activities as well This res SPECTRUM ALL-IN-ONE JOURNAL FOR ENGINEERING STUDENTS ns ie, atvities in Fea which need to be included in appli 1 resumed as soon a startActivty is called by moving tot Nn Wing to top of activity stack. The ath ncn ing arden Testy 5 willbe repeated each time when startActivity and finish are called. = ‘Scanned with CamScanner rpu-HYDERABAD) sgett means tat hess cgotivity 10 be started. Poy implicit my sing a imi ne oe nei Fy ves of ich eve ipl. itis && y ( sntent n= 80” ct ent ACTIONZ startActiviy Gi es iat action on telephone ; at of data canbe psien mine Lisa mechanism that tach, ra Mura mestiod on ay itn se averon be wsed to erewe extra stored primitive values 027 inte te pei(typel EX! ethod can be wsed FOF i : ee ; class that iS prefers io peyote ie i wl a sn ie te Fo ity oF other Pelee ee an ule cass whee the mui i ter it resolution is specified ‘through analysis of roadeast Receive. ‘rif about the following ‘até, Discuss In () . Passing data to intonts {uy Gotting results from activities j (i) Native actions. yon a : Model Papers, 2) ‘Answer t : (Passing Data to Intents oh : tris possible o pass data inners by adding itt intent objec usin putExta() method. 15 passed in the form of key a erent yes like int Hat lon ia ics These are the SimPIG data types that can be egypt intent with uniawe KY ind forward to some otbet ‘serialization is used. value pair. Here, the value ca ich is needed 10 be done is 10 Pass perween te activities. In such CASE) passed easily. The ony thins r tis difclt in ease of passing custom objects {hun canbe sent assem belOW, Intent in= new Intent (context, “TargetActvity_clas) : i ie inputExtra(key, value) staitActivity(in); simile values tached by using patra) ethou: IF string objet Here a single alc pased in the same way i jeseat then it can be fetched as shown below, Intent in = getIntent( % ‘String $= in.getStringExtra(key); oe ae that is started by using startActivity method does not provi i garg ea sneaker ts np a at can be fetched by using getntxtr), getPoaExta dete. _Anactviy| aecvity can be state thatare opened in differen way. WARNING: xerowPhi otocopylng ofthis ok si CRIMINAL act: Anyone fod gyi LIABLE to,face LEGAL proceedi ings. ‘Scanned with CamScanner ee are mainly sed he situations wi ssa requis atinpt fom anther atv and reuns oO spactvites are launched precisa retin the eas yess 80 PETES SUC sexi intent nt’ PEO It ca be done by using SanAtvityForResit Pedr ie TS ean ei quest code ing of vette ial int Sub SI = , iheqeneae explicit, M yevod start Subl() . Pa { nent n= new Inenthis, My_Aery suatAetvitForesuli, Sub 51), ‘The blow code sippet laste the lane private static inl int Sub_ 59 =, private void tart Sub2() { Uni uri = Uri Prel'content. Galery hey, Ineatin=newinen niet ACTION PICK. wy StatActivityForesultin, Sub $2), ) iy clas), NPE ibd mpc, request code enacts ready feta in ste cth seReticaled be fishin Ths eed aco ena dea be pes ante iter RESULT_OK or activity RESULT CANCELLED. i ; d re acura cae ancamols oF etuing ares fom a substi as sho ba so ee feta sul acutely. © ston = (Baton findViewBylR db, bsl0ClL.itene new View Onl ene) ( uble void onClick{View v) { logs, = listviewgetSelecteditemta(); : Ui u= Uriparse("contents/hv"+s id); Intent rs = new Inten(Intent.ACTION_PICK, u, seiResult(RESULT_OK, res); finish), ) hs ‘Button b2 = (Button) find ViewByld(R id b3); & setOnClickListener(new ‘View. OnClickListenen( ) ( ‘ble void onClick(View v) ( ‘ResulRESULT_CANCELLED); Sih, 1 My SPECTRUM ALLIN-ONE JOURNAL FOR ENGINEERING STUDENTS XL ‘Scanned with CamScanner 8 MOBILE APPLICATION DEVE! oP ‘ ul sbaclivies Same OF ) Native Actions “The Native Android applications make use of intents fron I actions which are available as static string constants jn Intent clas (a) ACTION_ANSWER This action is used to open an activity to manage the incoming ells ing the tii a une! allows a8 fo Oy aime cific in fntents data Uy ‘This action is wsed to provide phone dialer and hen ntte cal byw nye at ae aR (9 ACTION_DIAL e ia fom tte dala URL rian used bain ack apliation log wihspcie ume 0H 1 Ante (@ ACTION_DELETE re ata at Infos data UR “This ation is used to nitate an ativity that allows deletion of speci (© ACTION EDIT “This action is sed to requests an activity which (. , ACTION_BUG_REPORT is used to show activity which can report the bu URI. can edit data at Intent's ‘This act (@) ACTION_CALL BUTTON ‘This action is triggered when hardware "eal button” is pressed. () ACTION_INSERT : | This action is seo open an acti that allows insertion of nee into specifi cursor in Intent data URL, ()-ACTION:SEND! This ation is wed to lunch an activity that forwards specified data in Intent @ ‘This action is used to launch a specific search a 3.1.3 Using Intent to Dial a Number or to ‘Send SMS Q15, How intent is used to dial a number? Model Pape, O49) Answer t activity_mainaxml ‘