private
String getMetaDataValue(String name, String def) {
String value = getMetaDataValue(name);
return
(value ==
null
) ? def : value;
}
private
String getMetaDataValue(String name) {
Object value =
null
;
PackageManager packageManager = context.getPackageManager();
ApplicationInfo applicationInfo;
try
{
applicationInfo = packageManager.getApplicationInfo(context
.getPackageName(),
128
);
if
(applicationInfo !=
null
&& applicationInfo.metaData !=
null
) {
value = applicationInfo.metaData.get(name);
}
}
catch
(NameNotFoundException e) {
throw
new
RuntimeException(
"Could not read the name in the manifest file."
, e);
}
if
(value ==
null
) {
throw
new
RuntimeException(
"The name '"
+ name
+
"' is not defined in the manifest file's meta data."
);
}
return
value.toString();
}