Created
January 4, 2019 09:09
-
-
Save michael-riha/08fc8cd83b373b14baaf41a3f5de735b to your computer and use it in GitHub Desktop.
Helper to get the PlayerLicenseKey from the Android Manifest for Bitmovin Analytics Android Collector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected String gePlayerLicenseKey() { | |
// https://blog.iangclifton.com/2010/10/08/using-meta-data-in-an-androidmanifest/ | |
try { | |
ApplicationInfo ai = getPackageManager().getApplicationInfo(this.getPackageName(), PackageManager.GET_META_DATA); | |
Bundle bundle = ai.metaData; | |
String playerApiKey = bundle.getString("BITMOVIN_PLAYER_LICENSE_KEY"); | |
return playerApiKey; | |
} catch (PackageManager.NameNotFoundException e) { | |
Log.e(TAG, "Failed to load meta-data, NameNotFound: " + e.getMessage()); | |
} catch (NullPointerException e) { | |
Log.e(TAG, "Failed to load meta-data, NullPointer: " + e.getMessage()); | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment