Android 2.3.3. nullPointerException. The program won't call the next xml.
<p>I have an android 4.0 app to be downgraded to android 2.3.3. When i downgraded I changed all the necessary errors from the xml. Then the file run normally. But after I took a picture, which is after calling the main xml, the program won't call the next xml. What could be the problem? Here is my code:</p>

<pre><code>    public class ContactTaggingActivity extends Activity {
     //initial declarations
     protected Button _button;
     protected ImageView _image;
     protected TextView _field;
     protected String _path;
     protected QuickContactBadge quickContactBadge1;
     protected QuickContactBadge quickContactBadge2;
     protected boolean _taken;
     protected Button btn;
     protected Button btn2;
     protected Button btn3;
     protected Button btn4;
     protected TextView txt;
      public Bitmap pic;


     protected static final String PHOTO_TAKEN = "photo_taken";

     @Override
     public void onCreate(Bundle savedInstanceState)
     {//launching of the application
         super.onCreate(savedInstanceState);
 //initial xml
 setContentView(R.layout.main);


 _image = ( ImageView ) findViewById( R.id.image );
 _field = ( TextView ) findViewById( R.id.field );
 _button = ( Button ) findViewById( R.id.button );
 _button.setOnClickListener( new ButtonClickHandler() );
  _path = Environment.getExternalStorageDirectory() + "/drawable"; 
     }

     //when button Take A Photo is pressed
     public class ButtonClickHandler implements View.OnClickListener
     {
 public void onClick( View view )
 {
  startCameraActivity();
 }

     }

     //when button Open Contact List is pressed
     public class ButtonClickHandler2 implements View.OnClickListener
     {
 public void onClick(View arg0) 
 {
        if (arg0 == btn) 
        {
            try 
            {
                Intent intent = new Intent(Intent.ACTION_PICK,                             ContactsContract.Contacts.CONTENT_URI);
                startActivityForResult(intent, 1);
            } 

            catch (Exception e) 
            {
                e.printStackTrace();
                Log.e("Error in intent : ", e.toString());
            }
        }

    }
     }

     //when button Exit Application is pressed
     public class ButtonClickHandler3 implements View.OnClickListener
     {
 public void onClick( View view )
 {
      closeApp();
 }

     }



     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data)
     {//processing of the user query
 super.onActivityResult(requestCode, resultCode, data);
 if(resultCode == RESULT_OK)
 {
     switch(requestCode)
     {

     //taking the picture
     case 0:
         Log.i( "MakeMachine", "resultCode: " + resultCode );
         switch( resultCode )
            {
            case 0:
                Log.i( "MakeMachine", "User cancelled" );
                break;

            case -1:

                onPhotoTaken();
                break;
            }
    //opening the contact list and tagging the contact   
     case 1:
          try {
            if (resultCode == Activity.RESULT_OK) 
            {
                Uri contactData = data.getData();
                Cursor cur = managedQuery(contactData, null, null, null, null);
                ContentResolver contect_resolver = getContentResolver();

                if (cur.moveToFirst()) 
                {
                    String id = cur.getString(cur.getColumnIndexOrThrow(ContactsContract.Contacts._ID));
                    String name = "";


                    Cursor phoneCur = contect_resolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,
                            ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { id }, null);

                    if (phoneCur.moveToFirst()) 
                    {
                        name = phoneCur.getString(phoneCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));

                    }
                   onPhotoTaken();
                   //calling the 3rd xml/layout
                 setContentView(R.layout.taggedphoto);
                 btn2 = (Button) findViewById(R.id.button2);
                 btn4 = (Button) findViewById(R.id.button4);
                 txt = (TextView) findViewById(R.id.textView1);
                 quickContactBadge2= ( QuickContactBadge ) findViewById( R.id.quickContactBadge2 );
                 quickContactBadge2.setImageBitmap(pic);

                   Log.e("name :***: ", name);
                   txt.append(name);
                   btn2.setOnClickListener(new ButtonClickHandler() );
                   btn4.setOnClickListener(new ButtonClickHandler3() );

                //making the picture taken as display image of the contact
                ByteArrayOutputStream streamy = new ByteArrayOutputStream(); 
                pic.compress(CompressFormat.PNG, 0, streamy); 
                 byte[] photo = streamy.toByteArray();
                ContentValues values = new ContentValues();  
                int photoRow = -1; 
                values.put(ContactsContract.Data.RAW_CONTACT_ID, 
                        ContentUris.parseId(contactData)); 
                values.put(ContactsContract.Data.IS_SUPER_PRIMARY, 1); 
                values.put(ContactsContract.CommonDataKinds.Photo.PHOTO, photo); 
                values.put(ContactsContract.Data.MIMETYPE, 
                        ContactsContract.CommonDataKinds.Photo.CONTENT_ITEM_TYPE); 
                if(photoRow &gt;= 0)
                { 
                    this.getContentResolver().update(
                            ContactsContract.Data.CONTENT_URI, 
                            values, 
                            ContactsContract.Data._ID + " = " + photoRow, null); 
                } 
                else 
                { 
                        this.getContentResolver().insert(
                                ContactsContract.Data.CONTENT_URI, 
                                values); 
                } 


                }

            }
        } 
          catch (IllegalArgumentException e) 
          {
            e.printStackTrace();
            Log.e("IllegalArgumentException :: ", e.toString());
          } 
          catch (Exception e) 
          {
            e.printStackTrace();
           Log.e("ERROR", "ERROR IN CODE: " + e.toString());
          }


     }
 }
    }


     protected void onPhotoTaken()
     {//verifying the picture taken by the camera and displaying it in the application
try
 {
 _taken = true;

 BitmapFactory.Options options = new BitmapFactory.Options();
 options.inSampleSize = 4;

 //calling the 2nd xml/layout
 setContentView(R.layout.contactlist);
 btn3 = (Button) findViewById(R.id.button3);
 quickContactBadge1= ( QuickContactBadge ) findViewById( R.id.quickContactBadge1 );
 btn = (Button) findViewById(R.id.button1);
 btn.setOnClickListener(new ButtonClickHandler2() );
 btn3.setOnClickListener(new ButtonClickHandler() );
 Bitmap bitmap = BitmapFactory.decodeFile( _path, options );
 quickContactBadge1.setImageBitmap(bitmap);
 pic=bitmap;
 _field.setVisibility( View.GONE );
  }

 catch (Exception e)
 {
        e.printStackTrace();
       Log.e("ERROR", "ERROR IN CODE: " + e.toString());
 }
     }

     //calling the hardware camera
     protected void startCameraActivity()
     {
 File file = new File( _path );
 Uri outputFileUri = Uri.fromFile( file );

 Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
 intent.putExtra( MediaStore.EXTRA_OUTPUT, outputFileUri );

 startActivityForResult( intent, 0 );
     }


     //closing the application
     protected void closeApp()
     {

 System.exit(0);
     }

    }
</code></pre>
