Android Context Get getAppKey(Context context)

Here you can find the source of getAppKey(Context context)

Description

get App Key

Declaration

public static String getAppKey(Context context) 

Method Source Code

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

import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

import android.os.Bundle;

public class Main {
    public static final String KEY_APP_KEY = "JPUSH_APPKEY";

    public static String getAppKey(Context context) {
        Bundle metaData = null;/*from  w w w. j a  va2 s  . c o  m*/
        String appKey = null;
        try {
            ApplicationInfo ai = context.getPackageManager()
                    .getApplicationInfo(context.getPackageName(),
                            PackageManager.GET_META_DATA);
            if (null != ai)
                metaData = ai.metaData;
            if (null != metaData) {
                appKey = metaData.getString(KEY_APP_KEY);
                if ((null == appKey) || appKey.length() != 24) {
                    appKey = null;
                }
            }
        } catch (NameNotFoundException e) {

        }
        return appKey;
    }
}

Related

  1. cacheJson(Context context, URI uri, String jsonSource)
  2. getSharedPreferences(Context context)
  3. getAndroidDBDir(Context context)
  4. getAnimId(Context paramContext, String paramString)
  5. getApp(Context ctx, String packageName)
  6. getAppVersion(Context context)
  7. getApplicationInfos(Context context)
  8. getApplicationMemoryClass(@Nonnull Context context)
  9. getApplicationMetaData(Context context, String key)