get Meta Data Integer from Manifest - Android App

Android examples for App:Manifest

Description

get Meta Data Integer 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 Integer getMetaDataInteger(Context context, String name) {
        Integer value = null;//from   w  w  w.  j  a  v  a2  s . c  o m

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

        return value;
    }
}

Related Tutorials