Hey guys;
I wanted to get a list of installed apps on a device **by** using `getInstalledApplications()` method from `MockPackageManager` class (Yes it is deprecated). I used the following code (in my activity):
MockPackageManager mpm = new MockPackageManager();
List<ApplicationInfo> appInfoList = mpm.getInstalledApplications(0);
But it gave me this error:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/test/mock/MockPackageManager;
then found this way (which worked):
// MockPackageManager mpm = new MockPackageManager();
List<ApplicationInfo> appInfoList = getPackageManager().getInstalledApplications(0);
I looked at Android docs but only found these:
> Class for retrieving various kinds of information related to the application packages that are currently installed on the device. You can find this class through getPackageManager(). [PackageManager docs]
> Return PackageManager instance to find global package information.[Context docs about getPackageManager()]
I really didn't understand why the first way is wrong and why I should first use `getPackageManager()` (what does is do?).
Tnx in advance.
P.S: Sorry if it is a simple(stupid!) question
I wanted to get a list of installed apps on a device **by** using `getInstalledApplications()` method from `MockPackageManager` class (Yes it is deprecated). I used the following code (in my activity):
MockPackageManager mpm = new MockPackageManager();
List<ApplicationInfo> appInfoList = mpm.getInstalledApplications(0);
But it gave me this error:
java.lang.NoClassDefFoundError: Failed resolution of: Landroid/test/mock/MockPackageManager;
then found this way (which worked):
// MockPackageManager mpm = new MockPackageManager();
List<ApplicationInfo> appInfoList = getPackageManager().getInstalledApplications(0);
I looked at Android docs but only found these:
> Class for retrieving various kinds of information related to the application packages that are currently installed on the device. You can find this class through getPackageManager(). [PackageManager docs]
> Return PackageManager instance to find global package information.[Context docs about getPackageManager()]
I really didn't understand why the first way is wrong and why I should first use `getPackageManager()` (what does is do?).
Tnx in advance.
P.S: Sorry if it is a simple(stupid!) question