why do we need intent filter in android? -


this might stupid question, not quite clear on answer.

  1. my implicit intent contains action, data & category (optional), pass while sending intent either through startactivity or startservice.

something do,

intent intent = new intent(intent.action_send); intent.settype("text/plain"); intent.putextra(android.content.intent.extra_text, "standing on moon!"); startactivity(intent); 

and have same operation done in different way, using intent filter in manifest file like

<activity android:name="shareactivity">     <intent-filter>         <action android:name="android.intent.action.send"/>         <category android:name="android.intent.category.default"/>         <data android:mimetype="text/plain"/>     </intent-filter> </activity> 

my question - both way declare same purpose, 2 different ways declared, hve different significance???

as recall, referencing application intent filter manifest file let other applications know capable of handling intent. therefore, if capable of sending mail , register way in manifest, application can use yours send e-mails.

this seen gallery applications. applications seldom create own unless gallery application. therefore, ask android system gallery/mail applications available, , let choose 1 list. when register application capable of handling intent find application in list.

i believe 1 main difference between two, programmatic instantiation not known other applications.


Comments