-2

By these code i can turn on the camera and capture the image. After capturing the image the image can show on activity. But i can not store the image on the mobile storage. I want to store the image on the mobile gallery after capturing. Thanks.

public class MainActivity extends AppCompatActivity {

   private static final int CAMERA_REQUEST = 1888;
   private ImageView imageView;

   @Override
   public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    this.imageView = (ImageView) this.findViewById(R.id.imageView1);
    Button photoButton = (Button) this.findViewById(R.id.button1);
    photoButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(cameraIntent, CAMERA_REQUEST);
        }
    });
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == CAMERA_REQUEST && resultCode == Activity.RESULT_OK) {
        Bitmap photo = (Bitmap) data.getExtras().get("data");
        imageView.setImageBitmap(photo);
    }
}

}
monir tuhin
  • 441
  • 3
  • 13
  • 27
  • http://stackoverflow.com/questions/31678146/saving-image-taken-from-camera-into-internal-storage – W4R10CK Jan 29 '17 at 10:27

1 Answers1

0

You need to give permission in the manifest file.

Kyll
  • 7,036
  • 7
  • 41
  • 64
hiashutoshsingh
  • 980
  • 2
  • 14
  • 41