Example usage for android.provider MediaStore EXTRA_SCREEN_ORIENTATION

List of usage examples for android.provider MediaStore EXTRA_SCREEN_ORIENTATION

Introduction

In this page you can find the example usage for android.provider MediaStore EXTRA_SCREEN_ORIENTATION.

Prototype

String EXTRA_SCREEN_ORIENTATION

To view the source code for android.provider MediaStore EXTRA_SCREEN_ORIENTATION.

Click Source Link

Document

The name of the Intent-extra used to control the orientation of a ViewImage or a MovieView.

Usage

From source file:org.cm.podd.report.activity.SettingActivity.java

private void captureImageFromCamera() {
    mCurrentPhotoUri = getImageUri();//from  w  w  w.  j av a 2s .  c o m
    Intent photoTakerIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    photoTakerIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1024 * 1024);
    photoTakerIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    photoTakerIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCurrentPhotoUri);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
        photoTakerIntent
                .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            photoTakerIntent.setClipData(ClipData.newRawUri("", mCurrentPhotoUri));
        }
    }
    startActivityForResult(photoTakerIntent, REQ_CODE_TAKE_IMAGE);
}

From source file:es.upv.riromu.arbre.main.MainActivity.java

/******************************************/
public void captureImage(View view) {
    try {// ww w .  j av a 2  s . c  o m
        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();
                //
                image_uri = Uri.fromFile(photoFile);
            } catch (IOException ex) {
                // Error occurred while creating the File
                Log.i(TAG, "Error");
            }
            // Continue only if the File was successfully created
            if (photoFile != null) {
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, image_uri);
                takePictureIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION,
                        getResources().getConfiguration().orientation);
                //    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,uriSavedImage);
                startActivityForResult(takePictureIntent, CAPTURE_IMAGE);
            }
        }
    } catch (Exception e) {
        Log.e(TAG, "Error" + e.getMessage());
    }
}

From source file:cl.gisred.android.InspActivity.java

private void tomarFoto(String name) {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    File photo = null;// w w  w. ja  v  a  2  s. co m
    try {
        // place where to store camera taken picture
        photo = PhotoUtils.createFile(name, "jpg", InspActivity.this);
        photo.delete();
    } catch (Exception e) {
        Log.v(getClass().getSimpleName(), "Can't create file to take picture!");
    }
    mImageUri = Uri.fromFile(photo);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageUri);
    intent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LOCKED);
    startActivityForResult(intent, ACTIVITY_SELECT_FROM_CAMERA);
}