Android 在背景中拍照

Take a picture in background on Android

所以我想使用相机意图

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

我想在拍摄图片时做一些事情,我的问题是我可以在后台进行拍摄,而在显示器上是其他东西而不是显示图片吗?在此先感谢您的帮助

这是a以前做的一个项目的片段,希望对你有帮助:

  // 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)



    }
}