Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View TowkayNew's full-sized avatar

TowkayNew of NOTCHBAD.com TowkayNew

View GitHub Profile
@TowkayNew
TowkayNew / isPackageEnabled.java
Last active August 29, 2015 14:18
Method to check whether Android package is installed and enabled
private boolean isPackageEnabled(String packageName, Context context) {
PackageManager pm = context.getPackageManager();
try {
ApplicationInfo ai = pm.getApplicationInfo(packageName, PackageManager.GET_ACTIVITIES);
return ai.enabled;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
}