package com.atmob.flutter_umeng;

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

public class Utils {

    public static String getUmengAppKey(Context context) {
        try {
            // 获取应用的 PackageManager
            PackageManager pm = context.getPackageManager();

            // 获取应用的 ApplicationInfo
            ApplicationInfo appInfo = pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);

            // 从 ApplicationInfo 中获取 meta-data
            String umengAppKey = appInfo.metaData.getString("UMENG_APPKEY");

            return umengAppKey;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
}
