Created
June 13, 2013 14:33
-
-
Save Aracem/5774152 to your computer and use it in GitHub Desktop.
Get a META-DATA from the AndroidManifest.xml file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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