Search code examples
androidandroid-activitylabeltitleintentfilter

Different activity title in different intent actions


I have one activity and three intet filters, each with different label set on, (AndroidManifiest.xml below)

    <activity android:name=".activities.RecordActivity">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="com.keitai.enigma.OPEN_RECORD" />
        </intent-filter>
        <intent-filter android:label="@string/newRecord">
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="com.keitai.enigma.NEW_RECORD" />
        </intent-filter>
        <intent-filter android:label="@string/editRecord">
            <category android:name="android.intent.category.DEFAULT" />
            <action android:name="com.keitai.enigma.EDIT_RECORD" />
        </intent-filter>
    </activity>

But activity title is not changing to label set in intent filter :( Activity always contains application label.

What I'm donig wrong?


Solution

  • Are you sure you don't have code that is setting the title explicitly?

    Are you sure that the OPEN_RECORD intent isn't the one being triggered every time?

    Have you tried debugging by making sure everything has a distinct label (application, activity, each intent-filter) and seeing what happens?

    I agree with you that what you expected to happen is what the docs say should happen. But it seems like the default <application> label is being used regardless. I'm afraid if one of the above ideas doesn't help, then I'm out of ideas. I might try it myself later on my system to see if it happens for me.


    http://developer.android.com/guide/topics/manifest/intent-filter-element.html#label

    android:label

    A user-readable label for the parent component. This label, rather than the one set by the parent component, is used when the component is presented to the user as having the capability described by the filter.

    ...

    The default value is the label set by the parent component. If the parent does not specify a label, the default is the label set by the element's label attribute.


    http://developer.android.com/guide/topics/manifest/manifest-intro.html#iconlabel

    Icons and Labels

    ...

    In every case, the icon and label set in a containing element become the default icon and label settings for all of the container's subelements. Thus, the icon and label set in the element are the default icon and label for each of the application's components. Similarly, the icon and label set for a component — for example, an element — are the default settings for each of the component's elements. If an element sets a label, but an activity and its intent filter do not, the application label is treated as the label for both the activity and the intent filter.

    ...