get Meta Data Boolean from manifest - Android App

Android examples for App:Manifest

Description

get Meta Data Boolean from manifest

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.util.Log;

public class Main {
    private static Boolean getMetaDataBoolean(Context context, String name) {
        Boolean value = false;/*from  w w w  .j a v a 2s  .  co m*/

        PackageManager pm = context.getPackageManager();
        try {
            ApplicationInfo ai = pm.getApplicationInfo(
                    context.getPackageName(), PackageManager.GET_META_DATA);
            value = ai.metaData.getBoolean(name);
        } catch (Exception e) {
            Log.d("sugar", "Couldn't find config value: " + name);
        }

        return value;
    }
}

Related Tutorials