You are checking only requestCode. You should check the value of resultCode also. When the user has successfully performed the action, the resultCode will be equal to RESULT_OK. If the user presses the back button then the resultCode will be RESULT_CANCELED. So your code must be modified like this.
protected void onActivityResult (int requestCode, int resultCode, Intent data) { if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) { //2