Mohammad Amin Moordani Mohammad Amin Moordani - 4 years ago 157
Android Question

getPackageManager Non-Static Error

i want to check a app is Installed on user device or not my class is extends fragment so i have to use

instead of
when i try i got Non-static error what is solution in this case?

here is my function code

private boolean appInstalledOrNot(String uri) {
PackageManager pm = Context.getPackageManager();
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;

Answer Source

You should use getActivity().getPackageManager()

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download