Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.Resources; public class Main { static boolean isCustomDebugEnabled_ = false; /** * Get the value of "io.branch.sdk.TestMode" entry in application manifest or from String res. * * @return value of "io.branch.sdk.TestMode" entry in application manifest or String res. * false if "io.branch.sdk.TestMode" is not added in the manifest or String res. */ public static boolean isTestModeEnabled(Context context) { if (isCustomDebugEnabled_) { return isCustomDebugEnabled_; } boolean isTestMode_ = false; String testModeKey = "io.branch.sdk.TestMode"; try { final ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); if (ai.metaData != null && ai.metaData.containsKey(testModeKey)) { isTestMode_ = ai.metaData.getBoolean(testModeKey, false); } else { Resources resources = context.getResources(); isTestMode_ = Boolean.parseBoolean(resources .getString(resources.getIdentifier(testModeKey, "string", context.getPackageName()))); } } catch (Exception ignore) { } return isTestMode_; } }