Could someone explain the following lines in the 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 are the fields in activity and intent filter important and when are they used/referred ? Sorry, i tried to read the documentation but still couldnt figure much out.
Thank you
This is the name of your Activity class, the dot at the front is shorthand notation for your package. So this actually stands for
com.your.package.name.AboutUs
which means your java file that represents this Activity is calledAboutUs.java
label is the string that gets shown in the launcher(if the activity is listed in the launcher) and at the top of the window when the activity is open.
intent filter defines the Intents that your activity "listens for" in order to launch.
Action and category are both fields that get set on an Intent before it is "fired off" into the system. The system will then look for any activities that match both the action and category and if it finds one then it will launch that activity, or if it finds multiple it will show the user all of them and let them pick.
In your case your the action you are listening for
com.example.app1.ABOUT
is a custom action that is specific to your app, not one of the systems actions.So here is what an intent that would start this particular activity might look like:
Note that because you've created a custom action, this intent does not require access to your
AboutUs.class
so this intent could technically be fired from any app on the device and it would launch into your activity.For the
ACTION
you have this answer and for the DEFAULT category you have this answerAn Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map. To declare your activity, open your manifest file and add an element as a child of the element like your example.
An element can also specify various intent filters—using the element—in order to declare how other application components may activate it.
Please refer to the http://developer.android.com/guide/components/activities.html