An OOM error occurs when you view the preview of a large wallpaper image on the main screen because the wallpaper image is too large.
Exception prompt:
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.exe cTransact (Binder. java: 276)
E/InputManagerService (177): at dalvik. system. NativeStart. run (Native Method)
Code Section:
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
......
Solution:
1. Adjust 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. Adjust bitmap size
Bitmap = Bitmap. createScaledBitmap (bitmap, 100,150, false );
3. Adjust temp storage
MOptions. inSampleSize = new byte [100*1024];
Reference: http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue