I've got a broadcast receiver that gets "android.intent.action.PACKAGE_ADDED" and "android.intent.action.PACKAGE_REPLACED" intents (so when a package is installed on the phone, my app gets an intent with the package name). But when I try to use the PackageManager to get the PackageInfo by package name, it's throwing a NameNotFoundException.
What reasons might there be for this (other than the package not existing, which obviously isn't the case)? I can't find much on permissions - is there one I'm missing that's causing a misleading error?
try {
id = UAppIDUtils.GetUAppID(ctx.getPackageManager().getPackageInfo(pkgName, PackageManager.GET_SIGNATURES));
} catch (NameNotFoundException e) {
id = null;
Log.v(TAG, "Error finding package info");
e.printStackTrace();
}
ctx is the context; pkgName is the package name.