Android examples for android.content:Context
get Meta Value from application
import android.app.Activity; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.os.Bundle; import android.telephony.TelephonyManager; import android.util.Base64; import android.view.View; import android.widget.Button; import android.widget.TextView; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main{ public static String getMetaValue(Context context, String metaKey) { Bundle metaData = null;// w w w . j ava 2s . co m String apiKey = null; if (context == null || metaKey == null) { return null; } try { ApplicationInfo ai = context.getPackageManager() .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (null != ai) { metaData = ai.metaData; } if (null != metaData) { apiKey = metaData.getString(metaKey); } } catch (NameNotFoundException e) { } return apiKey; } }