Спасибо. Я обязательно сделаю это. Это очень полезный совет.

ользую скрытое намерение сделать снимок. Я следил за работой, изложенной в этомруководство, Проблема, которую я имею, состоит в том, что дополнительное добавленное к Намерению не доставляется. Вот код, который я использую:

private void dispatchTakePictureIntent(Context context) {
        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        // Ensure that there's a camera activity to handle the intent
        if (takePictureIntent.resolveActivity(context.getPackageManager()) != null) {
            // Create the File where the photo should go
            File photoFile = null;
            try {
                photoFile = createImageFile(this.getActivity());
            } catch (IOException ex) {
                Log.e(TAG, "Error creating file: " + ex.toString());
                //TODO: 2017/1/24 - Handle file not created
                AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
                builder.setTitle("Error")
                        .setMessage(ex.toString());

                final AlertDialog dialog = builder.create();
                dialog.show();

            }
            // Continue only if the File was successfully created
            if (photoFile != null) {
                Uri photoURI = FileProvider.getUriForFile(context,
                        "com.example.myapp",
                        photoFile);
                //THIS EXTRA IS NOT BEING ADDED TO THE INTENT
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);

                galleryAddPic(context, photoFile.getAbsolutePath());
            }
        }
    }

КогдаonActivityResult метод запущен,Intent пустой. Вот этот код:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_TAKE_PHOTO && resultCode == RESULT_OK) {
        //These extras are empty. I have used the debug tool, and there is nothing in here. 
        Bundle extras = data.getExtras();
        //extras is null
        imageBitmap = (Bitmap) extras.get("data");
        previewImage.setImageBitmap(imageBitmap);
    }
}

Почему намерение пусто? Что мне нужно сделать, чтобы решить эту проблему?

Ответы на вопрос(1)

Ваш ответ на вопрос