Skip to content

Instantly share code, notes, and snippets.

@johnkil
Last active December 10, 2015 13:49
Show Gist options
  • Save johnkil/4443797 to your computer and use it in GitHub Desktop.
Save johnkil/4443797 to your computer and use it in GitHub Desktop.
Check if specify system shared library is installed.
/**
* Check if specify system shared library is installed.
*
* @param ctx {@link Context} instance
* @param libraryName System shared library name (ex. Google Maps library name "com.google.android.maps")
* @return true if system shared library is installed, else false
*/
public static boolean hasSystemSharedLibraryInstalled(Context ctx, String libraryName) {
boolean hasLibraryInstalled = false;
if (!TextUtils.isEmpty(libraryName)) {
String[] installedLibraries = ctx.getPackageManager().getSystemSharedLibraryNames();
if (installedLibraries != null) {
for (String s : installedLibraries) {
if (libraryName.equals(s)) {
hasLibraryInstalled = true;
break;
}
}
}
}
return hasLibraryInstalled;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment