Launcher App:墙纸太大造成设置墙纸时产生“OutOfMemoryError: bitmap size exceeds VM budget”
来源:互联网 发布:如何关闭qq游戏端口 编辑:程序博客网 时间:2024/04/29 17:09
在主屏的设置墙纸界面,由于墙纸图片太大,浏览墙纸大图的预览图时,产生了OOM错误。
异常提示:
E/InputManagerService( 177): Got RemoteException sending setActive(false) notification
E/InputManagerService( 177): android.os.DeadObjectException
E/InputManagerService( 177): at android.os.BinderProxy.transact(Native Method)
E/InputManagerService( 177): at com.android.internal.view.IInputMethodClient$Stub$Proxy.setActive(IInputMethodClient.java:158)
E/InputManagerService( 177): at com.android.server.InputMethodManagerService.unbindCurrentInputLocked(InputMethodManagerService.java:554)
E/InputManagerService( 177): at com.android.server.InputMethodManagerService.startInputLocked(InputMethodManagerService.java:616)
E/InputManagerService( 177): at com.android.server.InputMethodManagerService.startInput(InputMethodManagerService.java:700)
E/InputManagerService( 177): at com.android.internal.view.IInputMethodManager$Stub.onTransact(IInputMethodManager.java:113)
E/InputManagerService( 177): at com.android.server.InputMethodManagerService.onTransact(InputMethodManagerService.java:466)
E/InputManagerService( 177): at android.os.Binder.execTransact(Binder.java:276)
E/InputManagerService( 177): at dalvik.system.NativeStart.run(Native Method)
代码部分:
public class com.android.launcher.WallpaperChooser
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
findWallpapers();
setContentView(R.layout.wallpaper_chooser);
mOptions = new BitmapFactory.Options();
mOptions.inDither = false;
mOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
mOptions.inSampleSize = 2;// fix it
... ...
public void onItemSelected(AdapterView parent, View v, int position, long id) {
final ImageView view = mImageView;
Bitmap b = BitmapFactory.decodeResource(getResources(), IMAGE_IDS[position], mOptions);// here throw the OOMError
... ...
解决方法:
1、调整merory useage
mOptions.inSampleSize = 2;//return an image that is 1/2 the width/height of the original, and 1/4 the number of pixels.
2、调整bitmap size
bitmap = Bitmap.createScaledBitmap(bitmap, 100, 150, false);
3、调整temp storage
mOptions.inSampleSize = new byte[100 * 1024];
参考:http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue
- Launcher App:墙纸太大造成设置墙纸时产生“OutOfMemoryError: bitmap size exceeds VM budget”
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget解决方法
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget解决办法
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget解决方法
- android BitmapFactory的OutOfMemoryError: bitmap size exceeds VM budget解决方案
- android BitmapFactory的OutOfMemoryError: bitmap size exceeds VM budget解决方案
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget解决方法
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget解决方法
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- java.lang.OutOfMemoryError:bitmap size exceeds VM budget
- android BitmapFactory的OutOfMemoryError: bitmap size exceeds VM budget解决方案
- java.lang.OutOfMemoryError:bitmap size exceeds VM budget 如何解决
- java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- 完美解决java.lang.OutOfMemoryError: bitmap size exceeds VM budget
- 关于n字节对齐和sizeof的用法
- 程序员的八个级别
- 条款11: 在operator= 中处理"自我赋值"
- sizeof 用法总结2
- POJ 1019 Number Sequence
- Launcher App:墙纸太大造成设置墙纸时产生“OutOfMemoryError: bitmap size exceeds VM budget”
- 数据库连接字符串大全 之 SQL服务器篇
- about the storageof variables (arm7 platform)
- 数据结构——关于KMP算法的效率分析
- SQL Server中, DateTime (日期)型操作的 SQL语法(转载)
- extjs 根据不同的操作动态替换panel上的tbar
- C++文件流操作(耦合)
- 打造极速MyEclipse
- .net按格式导出到.txt文件