package com.SLGames.Android;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
public class GetMetadataValueUtils
{
public static String getMetaDataValue(String name, String def)
{
String value = getMetaDataValue(name);
return (value == null) ? def : value;
}
private static String getMetaDataValue(String name) {
Object value = null;
PackageManager packageManager = ApplicationContext.getContext().getPackageManager();
ApplicationInfo applicationInfo;
try
{
applicationInfo = packageManager.getApplicationInfo(ApplicationContext.getContext().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();
}
}
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
public class GetMetadataValueUtils
{
public static String getMetaDataValue(String name, String def)
{
String value = getMetaDataValue(name);
return (value == null) ? def : value;
}
private static String getMetaDataValue(String name) {
Object value = null;
PackageManager packageManager = ApplicationContext.getContext().getPackageManager();
ApplicationInfo applicationInfo;
try
{
applicationInfo = packageManager.getApplicationInfo(ApplicationContext.getContext().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();
}
}