我在显示一个显示所有已安装应用程序的对话框时得到了这个
E/AndroidRuntime( 1148): java.lang.OutOfMemoryError
E/AndroidRuntime( 1148): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
E/AndroidRuntime( 1148): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:596)
E/AndroidRuntime( 1148): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:444)
E/AndroidRuntime( 1148): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:832)
E/AndroidRuntime( 1148): at android.content.res.Resources.loadDrawable(Resources.java:2988)
E/AndroidRuntime( 1148): at android.content.res.Resources.getDrawable(Resources.java:1558)
E/AndroidRuntime( 1148): at android.app.ApplicationPackageManager.getDrawable(ApplicationPackageManager.java:712)
E/AndroidRuntime( 1148): at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:149)
E/AndroidRuntime( 1148): at android.content.pm.ComponentInfo.loadDefaultIcon(ComponentInfo.java:167)
E/AndroidRuntime( 1148): at android.content.pm.PackageItemInfo.loadIcon(PackageItemInfo.java:154)
E/AndroidRuntime( 1148): at android.content.pm.ResolveInfo.loadIcon(ResolveInfo.java:226)
在对话框中,我正在遍历 a并通过以下List
方式ResolveInfo
加载应用程序图标:
Drawable app_icon = allappslist.get(i).loadIcon(context.getPackageManager()));
但这有时会产生上面的错误......