Reputation: 8031
I understand the AndroidManifest.xml
is prepared at compile time and not runtime, is there any other way to populate metadata in the manifest without relying on hard coded strings? Maybe populating it somehow at compile time?
I currently have the following on my AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="@drawable/dt_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<meta-data
android:name="DataPath"
android:value=""
/> ...
I don't want to hard code the value and instead populate it somehow with the results from:
Environment.getExternalStorageDirectory()
Another application will later retrieve the value of DataPath
by utilizing the ApplicationInfo
's metaData property.
Upvotes: 1
Views: 1055
Reputation: 62189
I believe i read somewhere that its possible to assign the value at compile time but still not hard coding it
The best you can do is to assign a value from gradle via manifest placeholders.
Example:
android {
defaultConfig {
manifestPlaceholders = [hostName:"www.example.com"]
}
...
}
<intent-filter ... >
<data android:scheme="http" android:host="${hostName}" ... />
...
</intent-filter>
Upvotes: 3