我的应用程序会监听应用安装和卸载,每当发生此类事件时,它都会更新一些数据。这就是我的所作所为:
String appPackageName = ...; // new app's package name
PackageManager pm = MainApp.get().getPackageManager();
// update installed apps list
final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
List<ResolveInfo> ril = null;
try {
ril = pm.queryIntentActivities(mainIntent, 0);
} catch (Exception e) {
// what to do now???
// I need the info, I can't silently ignore it...
}
// continue using the data => in my case I update my database and add the new installed app
我得到以下例外:
Caused by: android.os.DeadObjectException: Transaction failed on small parcel; remote process probably died
at android.os.BinderProxy.transactNative(Native Method)
at android.os.BinderProxy.transact(Binder.java:503)
at android.content.pm.IPackageManager$Stub$Proxy.queryIntentActivities(IPackageManager.java:3949)
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:801)
... 14 more
java.lang.RuntimeException: Package manager has died
at android.app.ApplicationPackageManager.queryIntentActivitiesAsUser(ApplicationPackageManager.java:850)
at android.app.ApplicationPackageManager.queryIntentActivities(ApplicationPackageManager.java:793)
at... // => at ABOVE CODE BLOCK at ril = pm.queryIntentActivities(mainIntent, 0);
我认为只有在我的应用程序自行更新时才会发生这种情况,但似乎并非如此。一位用户告诉我,每次安装新应用程序时都会发生这种情况(如果他卸载应用程序并再次安装它,则会发生这种情况)。
任何想法我能在这做什么?