title: NullPointer Exception in android 2.3,its working fine in Galaxy nexus
body: <p>The below process of getting an Bitmap from an imageview is not working in Android 2.3,its working fine in Google nexus. IS there anything to change to work everywhere</p>
  
  <pre><code>ImageView thumbImage =(ImageView) findViewById(R.id.imageView1);
  
  thumbImage.setDrawingCacheEnabled(true);
  
  Bitmap pr = thumbImage.getDrawingCache();
  </code></pre>
  
  <p>The actual process I am using.</p>
  
  <pre><code>    zoomImage.setOnClickListener(new OnClickListener() {
  
                      @Override
                      public void onClick(View v) {
                          if (thumbImage.getDrawable() != null) {
                              try {
  
                                  thumbImage.setDrawingCacheEnabled(true);
                                  Bitmap pre = thumbImage.getDrawingCache();
                                  if (zoomDialog == null)
                                      zoomDialog = new Dialog(EachProduct.this,
                                              R.style.ingredienttheme);
                                  LayoutInflater lf = getLayoutInflater();
                                  final View w = lf.inflate(R.layout.zoom_dialog,
                                          null);
                                  zoomDialog.setContentView(w);
                                  zoomDialog.getWindow().getAttributes().windowAnimations = R.style.Animation;
                                  final ImageView z = (ImageView) zoomDialog
                                          .findViewById(R.id.imageView1);
                                  ImageView close = (ImageView) zoomDialog
                                          .findViewById(R.id.imageView2);
  
                                  Bitmap newimage = Bitmap.createScaledBitmap(pre,
                                          displayWidth - 25, displayWidth - 25, true);
  
                                  /*
                                   * ByteArrayOutputStream stream = new
                                   * ByteArrayOutputStream();
                                   * newimage.compress(Bitmap.CompressFormat.PNG, 100,
                                   * stream); byte[] byteArray = stream.toByteArray();
                                   * Bitmap a=BitmapFactory.decodeByteArray(byteArray,
                                   * 0, byteArray.length, o2);
                                   */
  
                                  z.setImageBitmap(newimage);
                                  close.setOnClickListener(new OnClickListener() {
                                      @Override
                                      public void onClick(View arg0) {
                                          z.setImageDrawable(null);
                                          // z=null;
                                          zoomDialog.cancel();
                                      }
                                  });
                                  zoomDialog.show();
                              } catch (OutOfMemoryError e) {
                                  // TODO: handle exception
                                  System.out.println(e.toString());
                              }
                          }
                      }
                  });
  </code></pre>
  
  <p>Logcat Error:</p>
  
  <pre><code>06-03 14:47:48.114: E/AndroidRuntime(14051): FATAL EXCEPTION: main
  06-03 14:47:48.114: E/AndroidRuntime(14051): java.lang.NullPointerException
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:374)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at com.sparx.maternity.activities.EachProduct$9.onClick(EachProduct.java:510)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at android.view.View.performClick(View.java:2485)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at android.view.View$PerformClick.run(View.java:9089)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at android.os.Handler.handleCallback(Handler.java:587)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at android.os.Handler.dispatchMessage(Handler.java:92)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at android.os.Looper.loop(Looper.java:123)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at android.app.ActivityThread.main(ActivityThread.java:3806)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at java.lang.reflect.Method.invokeNative(Native Method)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at java.lang.reflect.Method.invoke(Method.java:507)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
  06-03 14:47:48.114: E/AndroidRuntime(14051):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>