java - Android Manifest- intent filter and activity -


could explain following lines in manifest -

    <activity         android:name=".aboutus"         android:label="@string/app_name">         <intent-filter >             <action android:name="com.example.app1.about" />             <category android:name="android.intent.category.default"/>         </intent-filter>      </activity>     

how fields in activity , intent filter important , when used/referred ? sorry, tried read documentation still couldnt figure out.

thank you

android:name=".aboutus" 

this name of activity class, dot @ front shorthand notation package. stands com.your.package.name.aboutus means java file represents activity called aboutus.java

android:label="@string/app_name" 

label string gets shown in launcher(if activity listed in launcher) , @ top of window when activity open.

<intent-filter > ... </intent-filter> 

intent filter defines intents activity "listens for" in order launch.

<action android:name="com.example.app1.about" /> <category android:name="android.intent.category.default"/> 

action , category both fields set on intent before "fired off" system. system activities match both action , category , if finds 1 launch activity, or if finds multiple show user of them , let them pick.

in case action listening com.example.app1.about custom action specific app, not 1 of systems actions.

so here intent start particular activity might like:

intent = new intent(); i.setaction("com.example.app1.about"); i.addcategory("android.intent.category.default"); startactivity(i); 

note because you've created custom action, intent not require access aboutus.class intent technically fired app on device , launch activity.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -