Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save michael-riha/08fc8cd83b373b14baaf41a3f5de735b to your computer and use it in GitHub Desktop.
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
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