Android open camera from button

前端 未结 10 1602
無奈伤痛
無奈伤痛 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 04:00

    I know it is a bit late of a reply but you can use the below syntax as it worked with me just fine

    Camera=(Button)findViewById(R.id.CameraID);
    Camera.setOnClickListener(new OnClickListener() {
    
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent Intent3=new   Intent(MediaStore.INTENT_ACTION_STILL_IMAGE_CAMERA);
                startActivity(Intent3); 
            }
        });
    

提交回复
热议问题