Skip to content

Instantly share code, notes, and snippets.

@Aracem
Created June 13, 2013 14:33
Show Gist options
  • Save Aracem/5774152 to your computer and use it in GitHub Desktop.
Save Aracem/5774152 to your computer and use it in GitHub Desktop.
Get a META-DATA from the AndroidManifest.xml file
package com.acdroid.example;
public final class GetMetaData {
private GetMetaData() {
throw new AssertionError();
}
/**
* Returns the metadata value with the metadata name
*
* @param context
* @param metadataName
* @return value of the metadata
* @throws NameNotFoundInfo when the MetaData Name is not in the Manifest
*/
protected static String getMetaDataFromManifest(Context context, String metadataName) throws NameNotFoundException {
ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(
context.getApplicationContext().getPackageName(), PackageManager.GET_META_DATA);
Bundle bundle = appInfo.metaData;
return bundle.getString(metadataName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment