Why is decodeByteArray giving me a null pointer error
<p>I'm trying to pass a byte array from an image to an activity through a bundle</p>

<p>creating the byte array with </p>

<pre><code>            Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
            ByteArrayOutputStream picArray = new ByteArrayOutputStream(); 
            thumbnail.compress(CompressFormat.PNG, 0, picArray); 
            byte[] picData = picArray.toByteArray();
</code></pre>

<p>when i try to decode the byte array into a bitmap i get a null pointer exception which FC's (running on physical phone) </p>

<p>I've been going through line by line and this is the only thing creating an error</p>

<pre><code>            //grab byte array taken
            Intent sent = this.getIntent();
            Bundle arrayForPic = sent.getExtras();
            byte[] picArray = arrayForPic.getByteArray("pictureArray");

            //convert array into bitmap
            //null error happens HERE
            Bitmap thumbnail = BitmapFactory.
               decodeByteArray(picArray, 0, picArray.length);
</code></pre>

<p>the errors are</p>

<pre><code>FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.test/com.test.HandlePic}: java.lang.NullPointerException


Caused by: java.lang.NullPointerException
at com.test.HandlePic.onCreate(HandlePic.java:43)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1703)
</code></pre>

<p>line 43 is where the decodeByteArray is</p>
