Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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

import android.os.Bundle;

public class Main {

    public static String getMetaData(Context context, String key) {
        Bundle metaData = null;
        String value = null;
        if (context == null || key == null) {
            return null;
        }
        try {
            ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(),
                    PackageManager.GET_META_DATA);
            if (null != ai) {
                metaData = ai.metaData;
            }
            if (null != metaData) {
                value = metaData.getString(key);
            }
        } catch (PackageManager.NameNotFoundException e) {
            // Nothing to do
        }
        return value;
    }
}