 <p>Create a button in your XML layout and the add the attribute <code>android:onClick="takeAPicture"</code> then in your main activity create a method with the same name from the <code>onClick</code> attribute. </p> <pre><code>public void takeAPicture(View view){ Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(intent, IMAGE_CAPTURE); } </code></pre> <p>And just do another method for when you want to get the image from the gallery:</p> <pre><code>public void getImageFromGallery(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE); } </code></pre>