Example usage for android.provider MediaStore EXTRA_VIDEO_QUALITY

List of usage examples for android.provider MediaStore EXTRA_VIDEO_QUALITY

Introduction

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

Prototype

String EXTRA_VIDEO_QUALITY

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

Click Source Link

Document

The name of the Intent-extra used to control the quality of a recorded video.

Usage

From source file:com.example.zf_android.activity.MerchantEdit.java

private void show3Dialog(int type, final String uri) {
    AlertDialog.Builder builder = new AlertDialog.Builder(MerchantEdit.this);
    final String[] items = getResources().getStringArray(R.array.apply_detail_view);

    MerchantEdit.this.type = type;
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override//w w w  .j a  v  a 2s . c  o m
        public void onClick(DialogInterface dialog, int which) {

            switch (which) {
            case 0: {

                AlertDialog.Builder build = new AlertDialog.Builder(MerchantEdit.this);
                LayoutInflater factory = LayoutInflater.from(MerchantEdit.this);
                final View textEntryView = factory.inflate(R.layout.show_view, null);
                build.setView(textEntryView);
                final ImageView view = (ImageView) textEntryView.findViewById(R.id.imag);
                //               ImageCacheUtil.IMAGE_CACHE.get(uri, view);
                ImageLoader.getInstance().displayImage(uri, view, options);
                build.create().show();
                break;
            }

            case 1: {

                Intent intent;
                if (Build.VERSION.SDK_INT < 19) {
                    intent = new Intent(Intent.ACTION_GET_CONTENT);
                    intent.setType("image/*");
                } else {
                    intent = new Intent(Intent.ACTION_PICK,
                            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                }
                startActivityForResult(intent, REQUEST_UPLOAD_IMAGE);
                break;
            }
            case 2: {
                String state = Environment.getExternalStorageState();
                if (state.equals(Environment.MEDIA_MOUNTED)) {
                    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                    File outDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
                    if (!outDir.exists()) {
                        outDir.mkdirs();
                    }
                    File outFile = new File(outDir, System.currentTimeMillis() + ".jpg");
                    photoPath = outFile.getAbsolutePath();
                    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile));
                    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
                    startActivityForResult(intent, REQUEST_TAKE_PHOTO);
                } else {
                    CommonUtil.toastShort(MerchantEdit.this, getString(R.string.toast_no_sdcard));
                }
                break;
            }
            }
        }
    });

    builder.show();
}

From source file:com.afrozaar.jazzfestreporting.MainActivity.java

public void recordVideo(View view) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
    intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 10);

    // Workaround for Nexus 7 Android 4.3 Intent Returning Null problem
    // create a file to save the video in specific folder (this works for
    // video only)
    // mFileURI = getOutputMediaFile(MEDIA_TYPE_VIDEO);
    // intent.putExtra(MediaStore.EXTRA_OUTPUT, mFileURI);

    // set the video image quality to high
    //intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    // start the Video Capture Intent
    startActivityForResult(intent, RESULT_VIDEO_CAP);
}

From source file:com.juick.android.ThreadActivity.java

public void onClick(DialogInterface dialog, int which) {
    Intent intent;/*  ww w.  ja  va2  s  .c  o m*/
    switch (which) {
    case 0:
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");
        startActivityForResult(Intent.createChooser(intent, null), ACTIVITY_ATTACHMENT_IMAGE);
        break;
    case 1:
        intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
        boolean useTempFileForCapture = sp.getBoolean("useTempFileForCapture", true);
        if (useTempFileForCapture) {
            File file = NewMessageActivity.getPhotoCaptureFile();
            file.delete();
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
        } else {
            intent.putExtra(MediaStore.EXTRA_OUTPUT,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        }
        startActivityForResult(intent, ACTIVITY_ATTACHMENT_IMAGE);
        break;
    case 2:
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("video/*");
        startActivityForResult(Intent.createChooser(intent, null), ACTIVITY_ATTACHMENT_VIDEO);
        break;
    case 3:
        intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
        startActivityForResult(intent, ACTIVITY_ATTACHMENT_VIDEO);
        break;
    }
}

From source file:com.android.mms.ui.MessageUtils.java

public static void recordVideo(Activity activity, int requestCode, long sizeLimit) {
    // The video recorder can sometimes return a file that's larger than the max we
    // say we can handle. Try to handle that overshoot by specifying an 85% limit.
    /// M: media recoder can handle this issue,so mark it.
    //        sizeLimit *= .85F;

    int durationLimit = getVideoCaptureDurationLimit();

    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("recordVideo: durationLimit: " + durationLimit + " sizeLimit: " + sizeLimit);
    }//w  w  w .j  ava  2s. c o  m

    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
    intent.putExtra("android.intent.extra.sizeLimit", sizeLimit);
    intent.putExtra("android.intent.extra.durationLimit", durationLimit);
    /// M: Code analyze 009, For fix bug ALPS00241707, You can not add
    // capture video to Messaging after you preview it in Gallery. @{
    intent.putExtra(MediaStore.EXTRA_OUTPUT, TempFileProvider.SCRAP_VIDEO_URI);
    /// M: fix bug ALPS01043585
    intent.putExtra("CanShare", false);
    activity.startActivityForResult(intent, requestCode);
}

From source file:com.example.zf_android.trade.ApplyDetailActivity.java

private void setupItem(LinearLayout item, int itemType, final String key, final String value) {
    switch (itemType) {
    case ITEM_EDIT: {
        TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key);
        EditText etValue = (EditText) item.findViewById(R.id.apply_detail_value);

        if (!TextUtils.isEmpty(key))
            tvKey.setText(key);/*from   w ww .j  a va2  s  .  c o m*/
        if (!TextUtils.isEmpty(value))
            etValue.setText(value);
        break;
    }
    case ITEM_CHOOSE: {
        TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key);
        TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value);

        if (!TextUtils.isEmpty(key))
            tvKey.setText(key);
        if (!TextUtils.isEmpty(value))
            tvValue.setText(value);
        break;
    }
    case ITEM_UPLOAD: {
        TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key);
        final TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value);

        if (!TextUtils.isEmpty(key))
            tvKey.setText(key);
        tvValue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                uploadingTextView = tvValue;
                AlertDialog.Builder builder = new AlertDialog.Builder(ApplyDetailActivity.this);
                final String[] items = getResources().getStringArray(R.array.apply_detail_upload);
                builder.setItems(items, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        switch (which) {
                        case 0: {
                            Intent intent = new Intent();
                            intent.setType("image/*");
                            intent.setAction(Intent.ACTION_GET_CONTENT);
                            startActivityForResult(intent, REQUEST_UPLOAD_IMAGE);
                            break;
                        }
                        case 1: {
                            String state = Environment.getExternalStorageState();
                            if (state.equals(Environment.MEDIA_MOUNTED)) {
                                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                                File outDir = Environment
                                        .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
                                if (!outDir.exists()) {
                                    outDir.mkdirs();
                                }
                                File outFile = new File(outDir, System.currentTimeMillis() + ".jpg");
                                photoPath = outFile.getAbsolutePath();
                                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile));
                                intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
                                startActivityForResult(intent, REQUEST_TAKE_PHOTO);
                            } else {
                                CommonUtil.toastShort(ApplyDetailActivity.this,
                                        getString(R.string.toast_no_sdcard));
                            }
                            break;
                        }
                        }
                    }
                });
                builder.show();

            }
        });
        break;
    }
    case ITEM_VIEW: {
        TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key);
        ImageButton ibView = (ImageButton) item.findViewById(R.id.apply_detail_view);

        if (!TextUtils.isEmpty(key))
            tvKey.setText(key);
        ibView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent i = new Intent(ApplyDetailActivity.this, ImageViewer.class);
                i.putExtra("url", value);
                i.putExtra("justviewer", true);
                startActivity(i);
            }
        });
    }
    }
}

From source file:org.smilec.smile.student.CourseList.java

private void takepicture() {

    chkimg = 1;//from  w  w w .  j  ava  2 s.c o  m
    TakenImage = false;

    // check if external storage exist
    boolean mExternalStorageAvailable = false;
    boolean mExternalStorageWriteable = false;
    String state = Environment.getExternalStorageState();

    if (Environment.MEDIA_MOUNTED.equals(state)) {
        // We can read and write the media
        mExternalStorageAvailable = mExternalStorageWriteable = true;
    } else if (Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) {
        // We can only read the media
        mExternalStorageAvailable = true;
        mExternalStorageWriteable = false;
    } else {
        // Something else is wrong. It may be one of many other states, but all we need
        //  to know is we can neither read nor write
        mExternalStorageAvailable = mExternalStorageWriteable = false;
    }

    if (mExternalStorageAvailable == false || mExternalStorageWriteable == false) {
        showToast("We cannot take picture. Please check if the external storage available or writeable.");
        return;
    }

    // -----------------------------------------------------------------
    // Start Built-in Camera Activity
    // -----------------------------------------------------------------
    // define the file-name to save photo taken by Camera activity
    String img_filename = "new-photo-name.jpg";
    // create parameters for Intent with filename
    ContentValues values = new ContentValues();
    values.put(MediaStore.Images.Media.TITLE, img_filename);
    values.put(MediaStore.Images.Media.DESCRIPTION, "Image capture by camera");
    // imageUri is the current activity attribute, define and save it for
    // later usage (also in onSaveInstanceState)
    imageUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
    // imageUri =
    // getContentResolver().insert(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI,
    // values);

    // create new Intent
    camera_intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    camera_intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
    camera_intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

    startActivityForResult(camera_intent, IMAGECAPTURE_OK);

}

From source file:com.waz.zclient.pages.main.conversation.ConversationFragment.java

@Override
public void onRequestPermissionsResult(int requestCode, int[] grantResults) {
    if (assetIntentsManager.onRequestPermissionsResult(requestCode, grantResults)) {
        return;//  www  . ja  v a2 s . c om
    }

    switch (requestCode) {
    case OPEN_EXTENDED_CURSOR_IMAGES:
        if (PermissionUtils.verifyPermissions(grantResults)) {
            openExtendedCursor(ExtendedCursorContainer.Type.IMAGES);
        }
        break;
    case CAMERA_PERMISSION_REQUEST_ID:
        if (PermissionUtils.verifyPermissions(grantResults)) {
            Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1) {
                takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
            }
            startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
        } else {
            onCameraPermissionsFailed();
        }
        break;
    case FILE_SHARING_PERMISSION_REQUEST_ID:
        if (PermissionUtils.verifyPermissions(grantResults)) {
            for (Uri uri : sharingUris) {
                getStoreFactory().getConversationStore().sendMessage(AssetFactory.fromContentUri(uri),
                        assetErrorHandler);
            }
            sharingUris.clear();
        } else {
            ViewUtils.showAlertDialog(getActivity(), R.string.asset_upload_error__not_found__title,
                    R.string.asset_upload_error__not_found__message,
                    R.string.asset_upload_error__not_found__button, null, true);
        }
        break;
    case AUDIO_PERMISSION_REQUEST_ID:
        // No actions required if permission is granted
        // TODO: https://wearezeta.atlassian.net/browse/AN-4027 Show information dialog if permission is not granted
        break;
    case AUDIO_FILTER_PERMISSION_REQUEST_ID:
        if (PermissionUtils.verifyPermissions(grantResults)) {
            openExtendedCursor(ExtendedCursorContainer.Type.VOICE_FILTER_RECORDING);
        } else {
            Toast.makeText(getActivity(), R.string.audio_message_error__missing_audio_permissions,
                    Toast.LENGTH_SHORT).show();
        }
        break;
    case SAVE_IMAGE_PERMISSION_REQUEST_ID:
        if (PermissionUtils.verifyPermissions(grantResults)) {
            saveImageAssetToGallery();
        } else {
            unableToSaveImageNoPermissions();
        }
        break;
    default:
        break;
    }

}