Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;

public class Main {
    public static String getKey(Context context) {
        String key = "";
        try {
            ApplicationInfo applicationInfo = context.getPackageManager()
                    .getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            key = applicationInfo.metaData.getString("com.wzy.apikey");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return key;
    }
}