Android Utililty Methods Context Get

List of utility methods to do Context Get

Description

The list of methods to do Context Get are organized into topic(s).

Method

TypefacegetTypeface(Context context, String name)
Retrieve a type-face.
context = context.getApplicationContext();
Log.d(TAG, "name=" + name);
if (TYPEFACE_CACHE.containsKey(name)) {
    return TYPEFACE_CACHE.get(name);
Typeface typeface = Typeface.createFromAsset(context.getAssets(),
        name);
if (typeface != null) {
...
StringgetUserAgentString(Context context)
get User Agent String
if (userAgent == null) {
    try {
        Constructor<WebSettings> constructor = WebSettings.class
                .getDeclaredConstructor(Context.class,
                        WebView.class);
        constructor.setAccessible(true);
        try {
            WebSettings settings = constructor.newInstance(context,
...
StringgetVersion(Context context)
get Version
String version = null;
try {
    PackageInfo pInfo = context.getPackageManager().getPackageInfo(
            context.getPackageName(), PackageManager.GET_META_DATA);
    version = pInfo.versionName;
} catch (NameNotFoundException e1) {
return version;
...
intgetVersionCode(Context mContext)
get Version Code
int versionCode = 0;
try {
    versionCode = mContext.getPackageManager().getPackageInfo(
            mContext.getPackageName(), 0).versionCode;
} catch (PackageManager.NameNotFoundException e) {
    e.printStackTrace();
return versionCode;
...
StringgetVoiceSearchIMId(Context context)
get Voice Search IM Id
ComponentName voiceInputComponent = new ComponentName(
        "com.google.android.voicesearch",
        "com.google.android.voicesearch.ime.VoceInputMethdServce");
if (DEBUG)
    Log.i(TAG, "getVoiceSearchIMId(), Comonent name = "
            + voiceInputComponent.flattenToString() + ", id = "
            + voiceInputComponent.flattenToShortString());
return voiceInputComponent.flattenToShortString();
...