Hi, I am getting the following logs when i am changing the wallpaper for Homescreen.
Even i am recycling the bitmap is done when the wallpaper changes in OnWallpaperChanged(). Still i m getting the bellow error. 03-26 05:02:16.829: INFO/AC(1340): setWallpaper(InputStream 03-26 05:02:16.840: INFO/AC(1340): setWallpaper(InputStream, FileOutputStream) 03-26 05:02:16.889: INFO/WallpaperService(1059): Wallpaper is changed!!! 03-26 05:02:16.899: INFO/WallpaperService(1059): beginBroadcast()2 03-26 05:02:16.899: INFO/ApplicationContext(1694): com.lge.homecube 03-26 05:02:16.899: INFO/ApplicationContext(1694): applicationContext is not null 03-26 05:02:16.899: INFO/ApplicationContext(1694): make mWallpaper null 03-26 05:02:16.909: INFO/WallpaperService(1059): onWallpaperChanged0 03-26 05:02:16.909: INFO/WallpaperService(1059): notifyCallbacks() 03-26 05:02:16.909: INFO/ApplicationContext(1059): android 03-26 05:02:16.909: INFO/ApplicationContext(1059): applicationContext is not null 03-26 05:02:16.909: INFO/ApplicationContext(1059): make mWallpaper null 03-26 05:02:16.909: INFO/WallpaperService(1059): onWallpaperChanged1 03-26 05:02:16.909: INFO/WallpaperService(1059): notifyCallbacks() 03-26 05:02:16.989: WARN/dalvikvm(1694): threadid=3: thread exiting with uncaught exception (group=0x40013e70) 03-26 05:02:16.989: ERROR/AndroidRuntime(1694): Uncaught handler: thread main exiting due to uncaught exception 03-26 05:02:17.019: WARN/LockPatternKeyguardView(1059): LockpatternKeyguardView WallpaperIntentReceiver_getWallpaper start!!!! 03-26 05:02:17.019: INFO/ApplicationContext(1059): getWallpaper() 03-26 05:02:17.029: INFO/ApplicationContext(1059): android 03-26 05:02:17.029: INFO/ApplicationContext(1059): GetCurrentWallaper 03-26 05:02:17.029: INFO/ApplicationContext(1059): Normal image wallpaper 03-26 05:02:17.029: INFO/WallpaperService(1059): List Of Callbacks 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.bit...@43895170 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.graphics.Canvas.throwIfRecycled(Canvas.java:942) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.graphics.Canvas.drawBitmap(Canvas.java:962) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at com.lge.homecube.Workspace.dispatchDraw(Workspace.java:596) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewGroup.drawChild(ViewGroup.java:1484) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at com.lge.homecube.DragLayer.dispatchDraw(DragLayer.java:280) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewGroup.drawChild(ViewGroup.java:1484) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.View.draw(View.java:5862) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.widget.FrameLayout.draw(FrameLayout.java:352) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewGroup.drawChild(ViewGroup.java:1486) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.View.draw(View.java:5862) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.widget.FrameLayout.draw(FrameLayout.java:352) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at com.android.internal.policy.impl.PhoneWindow$DecorView.draw (PhoneWindow.java:1892) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewRoot.draw(ViewRoot.java:1239) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewRoot.performTraversals(ViewRoot.java:1049) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.view.ViewRoot.handleMessage(ViewRoot.java:1507) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.os.Handler.dispatchMessage(Handler.java:99) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.os.Looper.loop(Looper.java:123) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at android.app.ActivityThread.main(ActivityThread.java:3948) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at java.lang.reflect.Method.invokeNative(Native Method) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at java.lang.reflect.Method.invoke(Method.java:521) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:782) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) 03-26 05:02:17.079: ERROR/AndroidRuntime(1694): at dalvik.system.NativeStart.main(Native Method) 03-26 05:02:17.269: INFO/ApplicationContext(1059): Read wallpaper file. 03-26 05:02:17.629: INFO/DumpStateReceiver(1059): Added state dump to 1 crashes 03-26 05:02:22.819: DEBUG/PowerManagerService(1059): inVSleepStatefalse Please revert as early as possible. Your fast response will be highly appreciated. Thanks and regards Mohammed Sameer On Aug 18, 1:38 am, Flying Coder <[email protected]> wrote: > Hi Nivek, > Unfortunately, doing recycle on the drawable returned by > ContextWrapper.getWallpaper() results in a run-time exception the next > time the app is launched: attempt touserecycledbitmap. Though > curiously, if I launch the app again after receiving the exeption, it > works fine. I.e., run time exception every other launch. > > At any rate, thanks for the pointer to Romain Guy's blog -- I > wasn't aware of the onRetainNonConfigurationInstance method. Should > be useful in some cases. > > Cheers, > Steve > > On Aug 17, 10:53 am, Nivek <[email protected]> wrote: > > > > > When you change the device orientation, you app is closed and then > > reopened. > > > Android handles bitmaps a "special" way, you HAVE to explicitly > > recycle them as soon as you don't need them anymore... or they stay > > allocated in memory and NEVER get freed. > > > I have started to code an app which uses a set of ImageViews. To avoid > > allocation errors on orientation changes, I had to override the > > onDestroy() method this way : > > /* > > * (non-Javadoc) > > * > > * @see android.app.Activity#onDestroy() > > */ > > @Override > > protected void onDestroy() { > > super.onDestroy(); > > if (isFinishing()) { > > for (ImageView view : mImgViews) { > > Drawable toRecycle = view.getDrawable > > (); > > if (toRecycle != null) { > > ((BitmapDrawable) > > toRecycle).getBitmap().recycle(); > > } > > } > > } > > } > > > After this, If the orientation change time is too long, you have to > > store the data (bitmaps and whatever else you need) with > > onRetainNonConfigurationInstance() and get them back on reinit with > > getLastNonConfigurationInstance(). > > > This has been explained by Romain Guy on his blog > > :http://www.curious-creature.org/2009/02/16/faster-screen-orientation-... > > > On 17 août, 15:58, Flying Coder <[email protected]> wrote: > > > > This has been driving me nuts and I'm hoping someone will be able to > > > help me understand what is happening (or better yet, how to fix > > > it! ;-). > > > > I set the background image in one of my apps to the system wallpaper > > > image using the following code: > > > > Drawable wp = this.getWallpaper(); > > > background = (ImageView) findViewById(R.id.background); > > > background.setImageDrawable(wp); > > > > This seems to work fine, but periodically, I get the out of memory > > > error shown below. Actually, on the emulator, all I have to do is > > > repeatedly rotate the device and this error will consistently happen > > > after 10-12 rotations. On the G1, opening and closing the keyboard > > > doesn't seem to cause this, but I'll still get the failure every once > > > in a while. > > > > Is getWallpaper() actually making a copy of the image (I would have > > > thought I'd just get a refernece to the existingbitmap)? Do I need > > > to do anything special to free the image? > > > > 08-17 08:32:37.943: ERROR/dalvikvm-heap(1597): 614400-byte external > > > allocation too large for this process. > > > 08-17 08:32:37.943: ERROR/(1597): VM won't let us allocate 614400 > > > bytes > > > 08-17 08:32:38.054: DEBUG/AndroidRuntime(1597): Shutting down VM > > > 08-17 08:32:38.054: WARN/dalvikvm(1597): threadid=3: thread exiting > > > with uncaught exception (group=0x4000fe70) > > > 08-17 08:32:38.054: ERROR/AndroidRuntime(1597): Uncaught handler: > > > thread main exiting due to uncaught exception > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): > > > java.lang.OutOfMemoryError:bitmapsize exceeds VM budget > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.graphics.BitmapFactory.nativeDecodeFileDescriptor(Native > > > Method) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.graphics.BitmapFactory.decodeFileDescriptor(BitmapFactory.java: > > > 424) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.ApplicationContext.getCurrentWallpaperLocked > > > (ApplicationContext.java:523) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.ApplicationContext.peekWallpaper(ApplicationContext.java: > > > 515) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.ApplicationContext.getWallpaper(ApplicationContext.java: > > > 504) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.content.ContextWrapper.getWallpaper(ContextWrapper.java:201) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at ....onCreate > > > (MyApp.java:247) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.Instrumentation.callActivityOnCreate(Instrumentation.java: > > > 1123) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.ActivityThread.performLaunchActivity(ActivityThread.java: > > > 2231) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.ActivityThread.handleLaunchActivity(ActivityThread.java: > > > 2284) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.ActivityThread.access$1800(ActivityThread.java:112) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.os.Handler.dispatchMessage(Handler.java:99) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.os.Looper.loop(Looper.java:123) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > android.app.ActivityThread.main(ActivityThread.java:3948) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > java.lang.reflect.Method.invokeNative(Native Method) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > java.lang.reflect.Method.invoke(Method.java:521) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run > > > (ZygoteInit.java:782) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) > > > 08-17 08:32:38.313: ERROR/AndroidRuntime(1597): at > > > dalvik.system.NativeStart.main(Native Method)- Hide quoted text - > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

