How to display picture in imageview photo taken by camera in android

后端 未结 3 1420
走了就别回头了
走了就别回头了 2021-01-07 05:30

can anybody tell How to display picture in imageview photo taken by using front camera in android can anybody provide code

Thanks

3条回答
  •  自闭症患者
    2021-01-07 05:58

    Try this one

    public class TakingImage extends AppCompatActivity {
    
    private static final int CAMERA_REQUEST = 1888;
    private ImageView imageView;
    
    public void onCreate(Bundle savedInstance){
        super.onCreate(savedInstance);
        setContentView(R.layout.activity_choosing_photo);
        button = (Button)findViewById(R.id.button_select);
        imageView = (ImageView)findViewById(R.id.image_view);
        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 == RESULT_OK) {
            Bitmap photo = (Bitmap) data.getExtras().get("data");
            imageView.setImageBitmap(photo);
        }
    }
    

    activity_choosing_photo.xml

    
    

提交回复
热议问题