title: android studio taking photos
body: <p>hey i followed a tutorial for taking pictures in an android studios project but my app crashes without any log errors. any help would be appreciated. also if anyone knows how add pictures from the gallery into the imageview that would be great.</p>
  
  <pre><code>public class MainActivity extends Activity {
      Button bn;
      int REQUEST_CODE = 1;
      ImageView IMG;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          bn = (Button) findViewById(R.id.bn);
          IMG = (ImageView) findViewById(R.id.img);
          bn.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                  if(i.resolveActivity(getPackageManager())!= null){
                      startActivityForResult(i,REQUEST_CODE);
                  }
              }
          });
          }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      public void onActivityResult(int requestcode, int resultcode, Intent data){
          if(requestcode == REQUEST_CODE &amp;&amp; resultcode == RESULT_OK)
          {
              Bundle extras = data.getExtras();
              Bitmap imageBitmap = (Bitmap) extras.get("data");
              IMG.setImageBitmap(imageBitmap);
          }
      }
  
  } 
  </code></pre>