Search code examples
androidstringresourcesintentfilter

Can you define an Android intent-filter using a string resource?


I wanted to define the string name of my intent in the strings.xml file, and then bind that string to an intent filter, as so:

<intent-filter >
    <action android:name="@string/app_intent" >
    </action>

    <category android:name="android.intent.category.DEFAULT" >
    </category>
</intent-filter>

When i tried this however, i get various errors about the system could find no activity to handle my intent. I was trying to keep values (ie, the intent names) centralized instead of hard-coded in the manifest as well as in code. As it is, at least this lets me centralize it out of the application code, but i still have it hard-coded in the manifest.

Is this really impossible to do or is there some way to make it work?


Solution

  • Its not the issue with intent-filter, the issue is with android:name. android:name attribute is not taking string resource for activity name also. example <activity android:name="@string/app" android:label="@string/app_name"> is not valid in android.