hch
8 天以前 aaa822b7f20f04d9ae00fff5efa6c2ec7e2cd83c
Project/app/src/main/java/com/secondworld/univeralsdk/UniversalUtil.java
@@ -8,6 +8,7 @@
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PermissionInfo;
@@ -354,4 +355,47 @@
        return true;
    }
    public static String getMetaString(Activity activity, String key)
    {
        PackageManager _pkgMgr = activity.getPackageManager();
        ApplicationInfo _appInfo;
        try
        {
            _appInfo = _pkgMgr.getApplicationInfo(activity.getPackageName(),
                                                  PackageManager.GET_META_DATA);
            return _appInfo.metaData.getString(key);
        } catch (PackageManager.NameNotFoundException e)
        {
            e.printStackTrace();
        }
        return null;
    }
    public static int getMetaInt(Activity activity, String key)
    {
        LogUtil.i(TAG, "将要获取的MetaKey: " + key);
        PackageManager _pkgMgr = activity.getPackageManager();
        ApplicationInfo _appInfo;
        try
        {
            _appInfo = _pkgMgr.getApplicationInfo(activity.getPackageName(),
                                                  PackageManager.GET_META_DATA);
            return _appInfo.metaData.getInt(key);
        } catch (PackageManager.NameNotFoundException e)
        {
            e.printStackTrace();
        }
        return -1;
    }
    public static boolean isEmpty(String s) {
        if (null == s)
            return true;
        if (s.length() == 0)
            return true;
        if (s.trim().length() == 0)
            return true;
        return false;
    }
}