Android open camera from button

前端 未结 10 1585
無奈伤痛
無奈伤痛 2020-11-29 03:24

I hope this isn\'t a duplicate question but I am making an app that I want a button to open the camera app (the default android camera separately). How do I got about doing

10条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-29 03:53

    You can create a camera intent and call it as startActivityForResult(intent).

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    
       // start the image capture Intent
    startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    

提交回复
热议问题