Exception in setDrawingCache in Android 1.5?
        Posted  
        
            by sunil
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by sunil
        
        
        
        Published on 2010-04-20T07:09:06Z
        Indexed on 
            2010/04/20
            7:13 UTC
        
        
        Read the original article
        Hit count: 514
        
android
|nullpointerexception
Hi,
I am developing an application where I am using setDrawingCache and then once I get the Bitmap I destroy the cache by using destroyDrawingCache().
The application has been developed with Android SDK 1.6. When testing the application in emulator with Android 1.5 the application throws NullPointerException when try to manipulate the Bitmap returned by getDrawingCache(). It probably gives error since getDrawingCache returns null.
The interesting thing in this is that the NullPointerException comes only after I run the application twice or thrice. It means I am able to get the Bitmap for two times and then it throws this exception.
The error that I am getting is as below
java.lang.NullPointerException E/AndroidRuntime( 1036): at com.babbleville.HomeScreenActivity.resizeBitmap(HomeScreenActivity.java: 394) E/AndroidRuntime( 1036): at com.babbleville.HomeScreenActivity.access $0(HomeScreenActivity.java:392) E/AndroidRuntime( 1036): at com.babbleville.HomeScreenActivity $1.handleMessage(HomeScreenActivity.java:327) E/AndroidRuntime( 1036): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 1036): at android.os.Looper.loop(Looper.java:123) E/AndroidRuntime( 1036): at android.app.ActivityThread.main(ActivityThread.java:3948) E/AndroidRuntime( 1036): at java.lang.reflect.Method.invokeNative(Native Method) E/AndroidRuntime( 1036): at java.lang.reflect.Method.invoke(Method.java:521) E/AndroidRuntime( 1036): at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(ZygoteInit.java:782) E/AndroidRuntime( 1036): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540) E/AndroidRuntime( 1036): at dalvik.system.NativeStart.main(Native Method)
Can someone please let me know the problem?
Regards
Sunil
© Stack Overflow or respective owner