I'm recovering all the applications installed on the device and I stumbled upon this error.
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:300)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:811)
Caused by: java.lang.RuntimeException: Package manager has died
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:499)
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:485)
at com.name.package.MyClass$RetrieveApps.doInBackground(MyClass.java:363)
at com.name.package.MyClass$RetrieveApps.doInBackground(MyClass.java:1)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
... 4 more
Caused by: android.os.TransactionTooLargeException
at android.os.BinderProxy.transact(Native Method)
at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(IPackageManager.java:2165)
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:493)
... 9 more
In doInBackground() method i use this code to retrieve the installed apps.
PackageManager packageManager = getPackageManager();
List<ResolveInfo> mResolveInfo;
Intent queryIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER);
mResolveInfo = packageManager.queryIntentActivities(queryIntent, 0);
for (ResolveInfo ri : resolveInfos) {
Class class = new Class();
class.icon = ri.loadIcon(packageManager);
class.label = ri.loadLabel(packageManager);
class.packagename = ri.activityInfo.packageName;
class.packageclass = ri.activityInfo.name;
class.componentName = new ComponentName(class.packagename, class.packageclass);
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
i.setComponent(ai.componentName);
class.intent = i;
myArrayList.add(class);
The line where the crash occurs is this:
mResolveInfo = packageManager.queryIntentActivities(queryIntent, 0);
Reading on stack overflow I understand that this may be caused by the fact that you have many applications installed. The question now is, how can you solve? Is there any solution? If yes, which one? Thanks.
I'm looking for the same solution. Is there any way to do a partial list of installed applications?
I have the same problem in my app.
List<PackageInfo> packs = pm.getInstalledPackages(0);
If the user has a large number of apps I get this in logcat:
Caused by: java.lang.RuntimeException: Package manager has died at android.app.ApplicationPackageManager.getInstalledPackages(ApplicationPackageManager.java:424)
Caused by: android.os.TransactionTooLargeException at android.os.BinderProxy.transact(Native Method) at android.content.pm.IPackageManager$Stub$Proxy.getInstalledPackages(IPackageManager.java:2363)
Update!
I was able to figure out a way. See this answer that I gave in another post:
Package manager has died
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With