隨筆-1  評(píng)論-68  文章-98  trackbacks-0

          在主屏的設(shè)置墻紙界面,由于墻紙圖片太大,瀏覽墻紙大圖的預(yù)覽圖時(shí),產(chǎn)生了OOM錯(cuò)誤。

          異常提示:

          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、調(diào)整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、調(diào)整bitmap size

          bitmap = Bitmap.createScaledBitmap(bitmap, 100, 150, false);

          3、調(diào)整temp storage

          mOptions.inSampleSize = new byte[100 * 1024];

          參考:http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue

           

          本文來(lái)自CSDN博客,轉(zhuǎn)載請(qǐng)標(biāo)明出處:http://blog.csdn.net/netpirate/archive/2009/06/10/4257854.aspx

          posted on 2009-08-29 23:28 Xu Jianxiang 閱讀(332) 評(píng)論(0)  編輯  收藏 所屬分類: Android
          主站蜘蛛池模板: 双桥区| 准格尔旗| 龙井市| 麻栗坡县| 万荣县| 塔城市| 闵行区| 泰安市| 永寿县| 花莲县| 南丰县| 田东县| 清涧县| 马关县| 江永县| 云梦县| 资兴市| 凤凰县| 望奎县| 武邑县| 澎湖县| 新郑市| 庄河市| 永川市| 嵊泗县| 宁夏| 拉萨市| 谷城县| 玛纳斯县| 津市市| 寿阳县| 大渡口区| 乐清市| 金阳县| 达尔| 南皮县| 苏州市| 龙山县| 郓城县| 伊宁县| 宁强县|