Example usage for android.provider MediaStore EXTRA_OUTPUT

List of usage examples for android.provider MediaStore EXTRA_OUTPUT

Introduction

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

Prototype

String EXTRA_OUTPUT

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

Click Source Link

Document

The name of the Intent-extra used to indicate a content resolver Uri to be used to store the requested image or video.

Usage

From source file:com.lastsoft.plog.GamesFragment.java

public void captureBox(Game game) {
    theGame = game;/*from   w  w w.  ja  va  2  s .co m*/
    try {
        InputMethodManager inputManager = (InputMethodManager) mActivity
                .getSystemService(Context.INPUT_METHOD_SERVICE);

        inputManager.hideSoftInputFromWindow(mActivity.getCurrentFocus().getWindowToken(),
                InputMethodManager.HIDE_NOT_ALWAYS);
    } catch (Exception ignored) {
    }

    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(mActivity.getPackageManager()) != null) {
        // Create the File where the photo should go
        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) {
            photoUri = Uri.fromFile(photoFile);
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
            startActivityForResult(takePictureIntent, 0);
        }
    }
}

From source file:com.ccxt.whl.activity.ChatActivity.java

/**
 * ?//from   w  ww .  j  a  v a  2  s.c o  m
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 0).show();
        return;
    }

    //      cameraFile = new File(PathUtil.getInstance().getImagePath(), DemoApplication.getInstance().getUserName()
    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            DemoApplication.getInstance().getUser() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

From source file:co.taqat.call.ChatFragment.java

private void pickImage() {
    List<Intent> cameraIntents = new ArrayList<Intent>();
    Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    File file = new File(Environment.getExternalStorageDirectory(),
            getString(R.string.temp_photo_name_with_date).replace("%s",
                    String.valueOf(System.currentTimeMillis())));
    imageToUploadUri = Uri.fromFile(file);
    captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, imageToUploadUri);
    cameraIntents.add(captureIntent);/*from   w  w  w .  ja  va 2 s.  com*/

    Intent galleryIntent = new Intent();
    galleryIntent.setType("image/*");
    galleryIntent.setAction(Intent.ACTION_PICK);

    Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.image_picker_title));
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {}));

    startActivityForResult(chooserIntent, ADD_PHOTO);
}

From source file:com.wemolian.app.wml.ChatActivity.java

/**
 * ?/*from  w w w  .j av  a  2s.  c o  m*/
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", Toast.LENGTH_SHORT).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            WeMoLianApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

From source file:com.uddchina.youdingdan.MyDateActivity.java

/**
 * ?/*w w  w.j a  v a2  s  .c o m*/
 */
public void doPhoto() {
    // 
    Uri uri = null;
    String saveDir = Environment.getExternalStorageDirectory() + "/youdingdan";
    File dir = new File(saveDir);
    if (!dir.exists()) {
        dir.mkdir();
    }
    String filename = "ydd_register" + pic_position + ".PNG";
    path = saveDir + "/" + filename;
    File file = new File(path);
    try {
        if (file.exists()) {
            file.delete();
        }
        file.createNewFile();
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (Build.VERSION.SDK_INT >= 24) {
        uri = FileProvider.getUriForFile(MyDateActivity.this, "com.example.cameraalbumtest.fileprovider", file);
    } else {
        uri = Uri.fromFile(file);
    }
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    // ??
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    startActivityForResult(intent, 2);

    /*
      String state = Environment.getExternalStorageState();
      if (state.equals(Environment.MEDIA_MOUNTED)) {
    Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
    startActivityForResult(intent, 2);
      } else {
    Toast.makeText(this, "SD?", Toast.LENGTH_LONG).show();
      }*/
}

From source file:com.parttime.activity.ChatActivity.java

/**
 * ?//ww  w.ja  v a  2 s .  c o  m
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), "SD????", 0).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            PartTimeApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

From source file:com.openatk.rockapp.MainActivity.java

@Override
public void RockTakePicture(int id, String filepath, String filename) {
    // Get the new image path
    File path = new File(filepath);
    path.mkdirs();// ww  w. j a v a 2  s. c  om
    File image = new File(path, filename);
    try {
        image.createNewFile();
    } catch (IOException e) {
        Log.w("RockAppActivity",
                "Could not make file for image. " + image.getAbsolutePath() + " " + e.toString());
        return;
    }

    // Put together image capture intent
    Intent takePic = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    takePic.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image));

    // Fire intent
    startActivityForResult(Intent.createChooser(takePic, "Capture Image"), REQUEST_PICTURE);
}

From source file:doext.easemob.activity.ChatActivity.java

/**
 * ?//from  ww  w. j a  v a  2  s .c o m
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        String st = getResources()
                .getString(DoResourcesHelper.getIdentifier("sd_card_does_not_exist", "string", this));
        Toast.makeText(getApplicationContext(), st, 0).show();
        return;
    }

    cameraFile = new File(
            PathUtil.getInstance().getImagePath(), /* DemoApplication.getInstance().getUserName()*/
            +System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

From source file:com.ieeton.user.activity.ChatActivity.java

/**
 * ?//from ww  w  . j a  v  a 2  s  .  c  o  m
 */
public void selectPicFromCamera() {
    if (!CommonUtils.isExitsSdcard()) {
        Toast.makeText(getApplicationContext(), R.string.no_sdcard_for_capture, Toast.LENGTH_SHORT).show();
        return;
    }

    cameraFile = new File(PathUtil.getInstance().getImagePath(),
            IeetonApplication.getInstance().getUserName() + System.currentTimeMillis() + ".jpg");
    cameraFile.getParentFile().mkdirs();
    startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT,
            Uri.fromFile(cameraFile)), REQUEST_CODE_CAMERA);
}

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

public void onClick(DialogInterface dialog, int which) {
    Intent intent;//from w ww.  j a v a 2s .  co  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;
    }
}