0

カメラからアクティビティに画像を送信しようとしています。startActivityForResult私はこのように呼び出しますadapter:

photo.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        dialog.dismiss();
        mActivity.dispatchTakePictureIntent(part.getId());
    }
});

Activity のメソッドは次のとおりです。

public void dispatchTakePictureIntent(String id) {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File

        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            Uri photoURI = FileProvider.getUriForFile(this,
                    "com.example.eltegps011.eltegps.fileprovider",
                    photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
            takePictureIntent.putExtra("Id",id);

            startActivityForResult(takePictureIntent, CAM_REQUEST);
        }
    }
}

そして、これは私のonActivityResult()

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == 2) {
        part = (Part) data.getSerializableExtra("Part");
        Log.e(TAG, "onActivityResult: ");

}if(requestCode == 1313) {
    Bitmap thumbnail = (Bitmap)data.getExtras().get("data");
    String id = data.getStringExtra("Id");
    Log.e(TAG, "onActivityResult: " + id);
}

ただし、Bitmap thumbnail = (Bitmap)data.getExtras().get("data")isnullおよびresultCode は常に -1です。意図が通じないようactivityです。理由はありますか?

4

1 に答える 1