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.jigarmjoshi.ReportFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {

    rootView = inflater.inflate(R.layout.fragment_report, container, false);

    reportImageView = (ImageView) rootView.findViewById(R.id.reportImageView);
    this.cameraIconBitMap = BitmapFactory.decodeResource(getResources(), R.drawable.cam);

    p1ReportButton = (Button) rootView.findViewById(R.id.buttonReportP1);
    p1ReportButton.setBackgroundColor(Color.RED);
    p1ReportButton.setTextColor(Color.BLACK);

    p2ReportButton = (Button) rootView.findViewById(R.id.buttonReportP2);
    p2ReportButton.setBackgroundColor(Color.rgb(255, 100, 0)); // orange
    p2ReportButton.setTextColor(Color.BLACK);

    p3ReportButton = (Button) rootView.findViewById(R.id.buttonReportP3);
    p3ReportButton.setBackgroundColor(Color.rgb(255, 150, 0));
    p3ReportButton.setTextColor(Color.BLACK);

    reportImageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            File newFile = getImageFile();
            try {
                newFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();// ww w .  j a v  a2  s.c  o  m
            }

            Uri outputFileUri = Uri.fromFile(newFile);

            Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);

            startActivityForResult(cameraIntent, TAKE_PHOTO_CODE);
        }
    });

    p1ReportButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            performAction(Utility.P1);
        }

    });

    p2ReportButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            performAction(Utility.P2);
        }
    });

    p3ReportButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            performAction(Utility.P3);
        }
    });
    // Gets the MapView from the XML layout and creates it
    mapView = (MapView) rootView.findViewById(R.id.mapviewReport);
    mapView.onCreate(savedInstanceState);
    // Gets to GoogleMap from the MapView and does initialization stuff
    map = mapView.getMap();
    map.getUiSettings().setMyLocationButtonEnabled(true);
    // map.setMyLocationEnabled(true);
    mapView.refreshDrawableState();

    // Needs to call MapsInitializer before doing any CameraUpdateFactory
    // calls
    try {
        MapsInitializer.initialize(this.getActivity());
    } catch (Exception e) {
        e.printStackTrace();
    }
    Utility.focusAtCurrentLocation(map);
    return rootView;
}

From source file:com.mvc.imagepicker.ImagePicker.java

/**
 * Get an Intent which will launch a dialog to pick an image from camera/gallery apps.
 *
 * @param context      context.//from  www .  j av  a2 s  . c o m
 * @param chooserTitle will appear on the picker dialog.
 * @return intent launcher.
 */
public static Intent getPickImageIntent(Context context, String chooserTitle) {
    Intent chooserIntent = null;
    List<Intent> intentList = new ArrayList<>();

    Intent pickIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intentList = addIntentsToList(context, intentList, pickIntent);

    // Camera action will fail if the app does not have permission, check before adding intent.
    // We only need to add the camera intent if the app does not use the CAMERA permission
    // in the androidmanifest.xml
    // Or if the user has granted access to the camera.
    // See https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE
    if (!appManifestContainsPermission(context, Manifest.permission.CAMERA) || hasCameraAccess(context)) {
        Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        takePhotoIntent.putExtra("return-data", true);
        takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTemporalFile(context)));
        intentList = addIntentsToList(context, intentList, takePhotoIntent);
    }

    if (intentList.size() > 0) {
        chooserIntent = Intent.createChooser(intentList.remove(intentList.size() - 1), chooserTitle);
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
                intentList.toArray(new Parcelable[intentList.size()]));
    }

    return chooserIntent;
}

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

private void captureVideo(IntentType type) {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    pendingFileUri = getOutputMediaFileUri(IntentType.VIDEO);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, pendingFileUri);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 0);
    }//www.  j  av  a  2  s .  c o  m
    callback.openIntent(intent, type);
}

From source file:com.google.android.gms.samples.vision.face.photo.PhotoViewerActivity.java

private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
        if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
            // Create the File where the photo should go
            File photoFile = null;
            try {
                photoFile = createImageFile();
            } catch (IOException ex) {

            }/*from w w w  . j a  v  a 2s.  com*/
            // Continue only if the File was successfully created
            if (photoFile != null) {
                photoURI = Uri.fromFile(photoFile);
                takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoURI);
                startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
            }
        }

    }

}

From source file:com.android.contacts.util.ContactPhotoUtils.java

/**
 * Adds common extras to gallery intents.
 *
 * @param intent The intent to add extras to.
 * @param photoUri The uri of the file to save the image to.
 *///  ww  w.ja v a 2  s . com
public static void addPhotoPickerExtras(Intent intent, Uri photoUri) {
    intent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
    intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_READ_URI_PERMISSION);
    intent.setClipData(ClipData.newRawUri(MediaStore.EXTRA_OUTPUT, photoUri));
}

From source file:com.narkii.security.info.LicenseInfoFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onActivityCreated(savedInstanceState);

    fileButton = (Button) view.findViewById(R.id.button_add_local);
    captureButton = (Button) view.findViewById(R.id.button_add_capture);
    uploadButton = (Button) view.findViewById(R.id.button_upload);
    previewImage = (ImageView) view.findViewById(R.id.image_preview);
    gridView = (GridView) view.findViewById(R.id.image_uploaded);
    fileName = (EditText) view.findViewById(R.id.text_file_name);

    gridViewAdapter = new GridViewAdapter(getActivity(), null, false);
    gridView.setAdapter(gridViewAdapter);

    captureButton.setOnClickListener(new OnClickListener() {

        @Override/*from   w w  w  . j a  v  a  2 s.  c o m*/
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            fileUri = MediaFileStorage.getOutputMediaFileUri(MediaFileStorage.MEDIA_TYPE_IMAGE);
            Log.d(TAG, fileUri.toString());
            Log.d(TAG, fileUri.getPath());
            i.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
            getParentFragment().startActivityForResult(i, Constants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        }
    });

    fileButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent intent = new Intent();
            intent.setType("*/*"); //("image/*")
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            //FragmentFragmentFragmentFragmentResultFragment
            getParentFragment().startActivityForResult(intent, Constants.CONTENT_GET_ACTIVITY_REQUEST_CODE);
        }
    });
    uploadButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            if (preBitmap != null && !fileName.getText().toString().equals("")) {
                //
                new Thread(new Runnable() {

                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        DbOperations operations = DbOperations.getInstance(getActivity());
                        ContentValues values = new ContentValues();
                        values.put(Permission.COLUMN_FK_ENTERPRISE_ID,
                                getArguments().getLong("enterpriseId", 0));
                        Log.d(TAG, "storage file:" + fileUri.toString());
                        Log.d(TAG, "storage file:" + fileUri.getPath());
                        values.put(Permission.COLUMN_URL, fileUri.toString());
                        values.put(Permission.COLUMN_CERTIFICATE_NAME, fileName.getText().toString());
                        if (isImage)
                            values.put(Permission.COLUMN_TYPE, 1);
                        else
                            values.put(Permission.COLUMN_TYPE, 2);
                        long result = operations.insert(Permission.TABLE_NAME, values);
                        if (result > 0) {
                            Message msg = new Message();
                            msg.what = Constants.INSERT_UPLOADED_OK_MSG;
                            handler.sendMessage(msg);
                        }
                    }
                }).start();
            } else {
                Toast.makeText(getActivity(), "please select file and input name", Toast.LENGTH_LONG).show();
            }
        }
    });

    long id = getArguments().getLong("enterpriseId", 0);
    Bundle bundle = new Bundle();
    bundle.putLong("id", id);
    getLoaderManager().initLoader(Constants.PERMISSION_IMAGE_ID, bundle, this);
}

From source file:eu.geopaparazzi.library.camera.AbstractCameraActivity.java

protected void doTakePicture(Bundle icicle) {
    Bundle extras = getIntent().getExtras();
    File imageSaveFolder = null;//  ww  w  .  j  av  a2s .c  o  m
    try {
        imageSaveFolder = ResourcesManager.getInstance(this).getTempDir();
        String imageName;
        if (extras != null) {
            String imageSaveFolderTmp = extras.getString(LibraryConstants.PREFS_KEY_CAMERA_IMAGESAVEFOLDER);
            if (imageSaveFolderTmp != null && new File(imageSaveFolderTmp).exists()) {
                imageSaveFolder = new File(imageSaveFolderTmp);
            }
            imageName = extras.getString(LibraryConstants.PREFS_KEY_CAMERA_IMAGENAME);
        } else {
            throw new RuntimeException("Not implemented yet...");
        }

        if (!imageSaveFolder.exists()) {
            if (!imageSaveFolder.mkdirs()) {
                Runnable runnable = new Runnable() {
                    public void run() {
                        finish();
                    }
                };
                GPDialogs.warningDialog(this, getString(R.string.cantcreate_img_folder), runnable);
                return;
            }
        }

        File mediaFolder = imageSaveFolder;

        currentDate = new Date();

        if (imageName == null) {
            imageName = ImageUtilities.getCameraImageName(currentDate);
        }

        imageFilePath = mediaFolder.getAbsolutePath() + File.separator + imageName;
        File imgFile = new File(imageFilePath);
        Uri outputFileUri = Utilities.getFileUriInApplicationFolder(this, imgFile);

        Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);

        lastImageMediastoreId = getLastImageMediaId();

        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
    } catch (Exception e) {
        GPLog.error(this, null, e);
        GPDialogs.errorDialog(this, e, new Runnable() {
            @Override
            public void run() {
                finish();
            }
        });
    }

}

From source file:com.whamads.nativecamera.NativeCameraLauncher.java

public void takePicture() {
    // Save the number of images currently on disk for later
    Intent intent = new Intent(this.cordova.getActivity().getApplicationContext(), CameraActivity.class);
    this.photo = createCaptureFile();
    this.imageUri = Uri.fromFile(photo);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, this.imageUri);
    this.cordova.startActivityForResult((CordovaPlugin) this, intent, 1);
}

From source file:com.univpm.s1055802.faceplusplustester.Detect.AcquireVideo.java

/**
 * Richiama la fotocamera, acquisisce il video e lo salva in un file
 * @return il file salvato//from   w w  w .  j a va  2  s  . co m
 */
private void Acquire() {
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    videoFile = null;
    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        // Create the File where the photo should go

        try {
            videoFile = createVideoFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
            Log.v("alert", "file error");
        }
        // Continue only if the File was successfully created
        if (videoFile != null) {
            takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(videoFile));
            takeVideoIntent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);

            startActivityForResult(takeVideoIntent, REQUEST_TAKE_VIDEO);
        }
    }
}

From source file:com.royclarkson.springagram.PhotoAddFragment.java

private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
        // Create the File where the photo should go
        File photoFile = null;//from  www . j  ava2s . c o  m
        try {
            photoFile = createImageFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
        }
        // Continue only if the File was successfully created
        if (photoFile != null) {
            takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
            startActivityForResult(takePictureIntent, REQUEST_TAKE_PHOTO);
        }
    }
}