相机意图 - 存储已满

时间:2015-07-29 10:13:13

标签: android android-intent camera

当我按下init时,默认的相机应用程序启动。

我的问题是它说存储已满。 当我启动Camera应用程序时,错误没有显示出来。

以下是相机意图的代码:

photoButton
onCreate()方法中的

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
        case CAMERA_PIC_REQUEST: {
            try {
                Bitmap image = (Bitmap) data.getExtras().get("data");
                ImageView imageView = (ImageView) findViewById(R.id.taskPhotoImage);
                imageView.setImageBitmap(image);

            } catch (NullPointerException e) {
                e.printStackTrace();
            }
        }
        case REQ_CODE_SPEECH_INPUT: {
            if (resultCode == RESULT_OK && null != data) {
                ArrayList<String> result = data
                        .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
                textField.setText(textField.getText() + " " + result.get(0));
            }
            break;
        }
    }
}

我不知道代码中是否存在问题。但看起来出现了问题

亲切的问候

2 个答案:

答案 0 :(得分:0)

试试这个: -

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

    // After camera screen this code will excuted

    if (requestCode == CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE) {

        if (resultCode == RESULT_OK) {

            output.setText("Video File : " +data.getData());

            // Video captured and saved to fileUri specified in the Intent
            Toast.makeText(this, "Video saved to:" + data.getData(), Toast.LENGTH_LONG).show();

        } else if (resultCode == RESULT_CANCELED) {

            output.setText("User cancelled the video capture.");

            // User cancelled the video capture
            Toast.makeText(this, "User cancelled the video capture.", 
                    Toast.LENGTH_LONG).show();

        } else {

            output.setText("Video capture failed.");

            // Video capture failed, advise user
            Toast.makeText(this, "Video capture failed.", 
                    Toast.LENGTH_LONG).show();
        }
    }
}

答案 1 :(得分:0)

试试这个

 @Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case TAKE_PICTURE:
    if (resultCode == Activity.RESULT_OK) {
        Uri selectedImage = imageUri;
        getContentResolver().notifyChange(selectedImage, null);
        ImageView imageView = (ImageView) findViewById(R.id.ImageView);
        ContentResolver cr = getContentResolver();
        Bitmap bitmap;
        try {
             bitmap = android.provider.MediaStore.Images.Media
             .getBitmap(cr, selectedImage);

            imageView.setImageBitmap(bitmap);
            Toast.makeText(this, selectedImage.toString(),
                    Toast.LENGTH_LONG).show();
        } catch (Exception e) {
            Toast.makeText(this, "Failed to load", Toast.LENGTH_SHORT)
                    .show();
            Log.e("Camera", e.toString());
        }
    }
}}

如果你想要相机意图

    private static final int TAKE_PICTURE = 1;    
private Uri imageUri;

public void takePhoto(View view) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
File photo = new File(Environment.getExternalStorageDirectory(),  "picture.jpg");
intent.putExtra(MediaStore.EXTRA_OUTPUT,
        Uri.fromFile(photo));
imageUri = Uri.fromFile(photo);
startActivityForResult(intent, TAKE_PICTURE);
}