简体   繁体   English

在Android的背景上拍照

[英]Take a picture in background on Android

So I want to use the camera intent 所以我想用相机的意图

Intent intent =new Intent("android.media.action.IMAGE_CAPTURE");

and I want to do something while the picture is capturing, and my question is can I do the capturing in background while on the display is something else and than show the picture ?. 我想在拍摄图片时做点什么,我的问题是我可以在显示器上进行背景拍摄而不是显示图片吗? Thanks in advance for help 预先感谢您的帮助

This is a snippet from a project a did before, I hope it will help you: 这是以前做过的一个项目的片段,希望对您有所帮助:

  // Open the camera and take a picture
public void openCamera() {
    Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
    getIntent.setType("image/*");
    startActivityForResult(getIntent, SEND_MESSAGE_IMG_REQUEST_IMAGE_PICK);
}

// handle the result from camera
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == SEND_MESSAGE_IMG_REQUEST_IMAGE_PICK && resultCode == RESULT_OK) {

        Uri selectedImage = data.getData();
        String[] filePathColumn = {MediaStore.Images.Media.DATA};

        Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
        String filePath = cursor.getString(columnIndex);
        cursor.close();

        // do a background task to handle the captured image (upload it to a server or something like that)



    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM