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.mercandalli.android.apps.files.file.FileAddDialog.java

@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
public FileAddDialog(@NonNull final Activity activity, final int id_file_parent,
        @Nullable final IListener listener, @Nullable final IListener dismissListener) {
    super(activity, R.style.DialogFullscreen);
    mActivity = activity;/*from ww  w.  j  a v a 2s . co m*/
    mDismissListener = dismissListener;
    mFileParentId = id_file_parent;
    mListener = listener;

    setContentView(R.layout.dialog_add_file);
    setCancelable(true);

    final View rootView = findViewById(R.id.dialog_add_file_root);
    rootView.startAnimation(AnimationUtils.loadAnimation(mActivity, R.anim.dialog_add_file_open));
    rootView.setOnClickListener(this);

    findViewById(R.id.dialog_add_file_upload_file).setOnClickListener(this);
    findViewById(R.id.dialog_add_file_add_directory).setOnClickListener(this);

    findViewById(R.id.dialog_add_file_text_doc).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogUtils.prompt(mActivity, mActivity.getString(R.string.dialog_file_create_txt),
                    mActivity.getString(R.string.dialog_file_name_interrogation),
                    mActivity.getString(R.string.dialog_file_create),
                    new DialogUtils.OnDialogUtilsStringListener() {
                        @Override
                        public void onDialogUtilsStringCalledBack(String text) {
                            //TODO create a online txt with content
                            Toast.makeText(getContext(), getContext().getString(R.string.not_implemented),
                                    Toast.LENGTH_SHORT).show();
                        }
                    }, mActivity.getString(android.R.string.cancel), null);
            FileAddDialog.this.dismiss();
        }
    });

    findViewById(R.id.dialog_add_file_scan).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            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
                ApplicationActivity.sPhotoFile = createImageFile();
                // Continue only if the File was successfully created
                if (ApplicationActivity.sPhotoFile != null) {
                    if (listener != null) {
                        ApplicationActivity.sPhotoFileListener = listener;
                    }
                    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
                            Uri.fromFile(ApplicationActivity.sPhotoFile.getFile()));
                    mActivity.startActivityForResult(takePictureIntent, ApplicationActivity.REQUEST_TAKE_PHOTO);
                }
            }
            FileAddDialog.this.dismiss();
        }
    });

    findViewById(R.id.dialog_add_file_add_timer).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            final Calendar currentTime = Calendar.getInstance();

            DialogDatePicker dialogDate = new DialogDatePicker(mActivity,
                    new DatePickerDialog.OnDateSetListener() {
                        @Override
                        public void onDateSet(DatePicker view, final int year, final int monthOfYear,
                                final int dayOfMonth) {

                            Calendar currentTime = Calendar.getInstance();

                            DialogTimePicker dialogTime = new DialogTimePicker(mActivity,
                                    new TimePickerDialog.OnTimeSetListener() {
                                        @Override
                                        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                                            Log.d("TIme Picker", hourOfDay + ":" + minute);

                                            final SimpleDateFormat dateFormatGmt = new SimpleDateFormat(
                                                    "yyyy-MM-dd HH:mm:ss", Locale.US);
                                            dateFormatGmt.setTimeZone(TimeZone.getTimeZone("UTC"));
                                            final SimpleDateFormat dateFormatLocal = new SimpleDateFormat(
                                                    "yyyy-MM-dd HH:mm:ss", Locale.US);

                                            String nowAsISO = dateFormatGmt.format(new Date());

                                            final JSONObject json = new JSONObject();
                                            try {
                                                json.put("type", "timer");
                                                json.put("date_creation", nowAsISO);
                                                json.put("timer_date",
                                                        "" + dateFormatGmt.format(dateFormatLocal.parse(year
                                                                + "-" + (monthOfYear + 1) + "-" + dayOfMonth
                                                                + " " + hourOfDay + ":" + minute + ":00")));

                                                final SimpleDateFormat dateFormatGmtTZ = new SimpleDateFormat(
                                                        "yyyy-MM-dd'T'HH-mm'Z'", Locale.US);
                                                dateFormatGmtTZ.setTimeZone(TimeZone.getTimeZone("UTC"));
                                                nowAsISO = dateFormatGmtTZ.format(new Date());

                                                final List<StringPair> parameters = new ArrayList<>();
                                                parameters.add(new StringPair("content", json.toString()));
                                                parameters.add(new StringPair("name", "TIMER_" + nowAsISO));
                                                parameters.add(
                                                        new StringPair("id_file_parent", "" + id_file_parent));
                                                new TaskPost(mActivity,
                                                        Constants.URL_DOMAIN + Config.ROUTE_FILE,
                                                        new IPostExecuteListener() {
                                                            @Override
                                                            public void onPostExecute(JSONObject json,
                                                                    String body) {
                                                                if (listener != null) {
                                                                    listener.execute();
                                                                }
                                                            }
                                                        }, parameters).execute();
                                            } catch (JSONException | ParseException e) {
                                                Log.e(getClass().getName(), "Failed to convert Json", e);
                                            }

                                        }
                                    }, currentTime.get(Calendar.HOUR_OF_DAY), currentTime.get(Calendar.MINUTE),
                                    true);
                            dialogTime.show();

                        }
                    }, currentTime.get(Calendar.YEAR), currentTime.get(Calendar.MONTH),
                    currentTime.get(Calendar.DAY_OF_MONTH));
            dialogDate.show();

            FileAddDialog.this.dismiss();
        }
    });

    findViewById(R.id.dialog_add_file_article).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            DialogCreateArticle dialogCreateArticle = new DialogCreateArticle(mActivity, listener);
            dialogCreateArticle.show();
            FileAddDialog.this.dismiss();
        }
    });

    FileAddDialog.this.show();
}

From source file:com.bilibili.boxing.utils.CameraPickerHelper.java

private void startCameraIntent(final Activity activity, final Fragment fragment, String subFolder,
        final String action, final int requestCode) {
    final String cameraOutDir = BoxingFileHelper.getExternalDCIM(subFolder);
    try {//from   w  w w  .  jav a 2 s  .com
        if (BoxingFileHelper.createFile(cameraOutDir)) {
            mOutputFile = new File(cameraOutDir, String.valueOf(System.currentTimeMillis()) + ".jpg");
            mSourceFilePath = mOutputFile.getPath();
            Intent intent = new Intent(action);
            Uri uri = getFileUri(activity.getApplicationContext(), mOutputFile);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
            try {
                startActivityForResult(activity, fragment, intent, requestCode);
            } catch (ActivityNotFoundException ignore) {
                callbackError();
            }

        }
    } catch (ExecutionException | InterruptedException e) {
        BoxingLog.d("create file" + cameraOutDir + " error.");
    }

}

From source file:ca.ualberta.cmput301.t03.inventory.AddItemView.java

/**
 * When the upload photos button is clicked an alert dialog will get created asking the
 * user if they want to upload a photo or take a photo, either option will result in a returned
 * bitmap which is handled in onActivityResult.
 *
 * Code used:/*from   www  . ja  va  2  s .co m*/
 * http://stackoverflow.com/questions/27874038/how-to-make-intent-chooser-for-camera-or-gallery-application-in-android-like-wha
 */
private void onUploadPhotosButtonClicked() {
    final CharSequence[] items = { "Take A Photo", "Choose Photo from Gallery" };

    AlertDialog.Builder builder = new AlertDialog.Builder(AddItemView.this);
    builder.setTitle("Attach Photo!");
    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int item) {
            if (item == 0) {
                Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                File f = new File(android.os.Environment.getExternalStorageDirectory(), "temp.jpg");
                intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f));
                startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
            } else if (item == 1) {
                Intent intent = new Intent(Intent.ACTION_PICK,
                        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                intent.setType("image/*");
                startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE);
            }
        }
    });
    builder.show();
}

From source file:com.layer.atlas.messenger.AtlasMessagesScreen.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.uiHandler = new Handler();
    this.app = (MessengerApp) getApplication();

    setContentView(R.layout.atlas_screen_messages);

    boolean convIsNew = getIntent().getBooleanExtra(EXTRA_CONVERSATION_IS_NEW, false);
    String convUri = getIntent().getStringExtra(EXTRA_CONVERSATION_URI);
    if (convUri != null) {
        Uri uri = Uri.parse(convUri);//from ww  w  . j  a va 2s  . c om
        conv = app.getLayerClient().getConversation(uri);
        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(convUri.hashCode()); // Clear notifications for this Conversation
    }

    participantsPicker = (AtlasParticipantPicker) findViewById(R.id.atlas_screen_messages_participants_picker);
    participantsPicker.init(new String[] { app.getLayerClient().getAuthenticatedUserId() },
            app.getParticipantProvider());
    if (convIsNew) {
        participantsPicker.setVisibility(View.VISIBLE);
    }

    messageComposer = (AtlasMessageComposer) findViewById(R.id.atlas_screen_messages_message_composer);
    messageComposer.init(app.getLayerClient(), conv);
    messageComposer.setListener(new AtlasMessageComposer.Listener() {
        public boolean beforeSend(Message message) {
            boolean conversationReady = ensureConversationReady();
            if (!conversationReady)
                return false;

            // push
            preparePushMetadata(message);
            return true;
        }

    });

    messageComposer.registerMenuItem("Photo", new OnClickListener() {
        public void onClick(View v) {
            if (!ensureConversationReady())
                return;

            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            String fileName = "cameraOutput" + System.currentTimeMillis() + ".jpg";
            photoFile = new File(getExternalFilesDir(android.os.Environment.DIRECTORY_PICTURES), fileName);
            final Uri outputUri = Uri.fromFile(photoFile);
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, outputUri);
            if (debug)
                Log.w(TAG, "onClick() requesting photo to file: " + fileName + ", uri: " + outputUri);
            startActivityForResult(cameraIntent, REQUEST_CODE_CAMERA);
        }
    });

    messageComposer.registerMenuItem("Image", new OnClickListener() {
        public void onClick(View v) {
            if (!ensureConversationReady())
                return;

            // in onCreate or any event where your want the user to select a file
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, "Select Picture"), REQUEST_CODE_GALLERY);
        }
    });

    messageComposer.registerMenuItem("Location", new OnClickListener() {
        public void onClick(View v) {
            if (!ensureConversationReady())
                return;

            if (lastKnownLocation == null) {
                Toast.makeText(v.getContext(), "Inserting Location: Location is unknown yet",
                        Toast.LENGTH_SHORT).show();
                return;
            }
            String locationString = "{\"lat\":" + lastKnownLocation.getLatitude() + ", \"lon\":"
                    + lastKnownLocation.getLongitude() + "}";
            MessagePart part = app.getLayerClient().newMessagePart(Atlas.MIME_TYPE_ATLAS_LOCATION,
                    locationString.getBytes());
            Message message = app.getLayerClient().newMessage(Arrays.asList(part));

            preparePushMetadata(message);
            conv.send(message);

            if (debug)
                Log.w(TAG, "onSendLocation() loc:  " + locationString);
        }
    });

    messagesList = (AtlasMessagesList) findViewById(R.id.atlas_screen_messages_messages_list);
    messagesList.init(app.getLayerClient(), app.getParticipantProvider());
    if (USE_QUERY) {
        Query<Message> query = Query.builder(Message.class)
                .predicate(new Predicate(Message.Property.CONVERSATION, Predicate.Operator.EQUAL_TO, conv))
                .sortDescriptor(new SortDescriptor(Message.Property.POSITION, SortDescriptor.Order.ASCENDING))
                .build();
        messagesList.setQuery(query);
    } else {
        messagesList.setConversation(conv);
    }

    messagesList.setItemClickListener(new ItemClickListener() {
        public void onItemClick(Cell cell) {
            if (Atlas.MIME_TYPE_ATLAS_LOCATION.equals(cell.messagePart.getMimeType())) {
                String jsonLonLat = new String(cell.messagePart.getData());
                JSONObject json;
                try {
                    json = new JSONObject(jsonLonLat);
                    double lon = json.getDouble("lon");
                    double lat = json.getDouble("lat");
                    Intent openMapIntent = new Intent(Intent.ACTION_VIEW);
                    String uriString = String.format(Locale.ENGLISH, "geo:%f,%f?z=%d&q=%f,%f", lat, lon, 18,
                            lat, lon);
                    final Uri geoUri = Uri.parse(uriString);
                    openMapIntent.setData(geoUri);
                    if (openMapIntent.resolveActivity(getPackageManager()) != null) {
                        startActivity(openMapIntent);
                        if (debug)
                            Log.w(TAG, "onItemClick() starting Map: " + uriString);
                    } else {
                        if (debug)
                            Log.w(TAG, "onItemClick() No Activity to start Map: " + geoUri);
                    }
                } catch (JSONException ignored) {
                }
            } else if (cell instanceof ImageCell) {
                Intent intent = new Intent(AtlasMessagesScreen.this.getApplicationContext(),
                        AtlasImageViewScreen.class);
                app.setParam(intent, cell);
                startActivity(intent);
            }
        }
    });

    typingIndicator = (AtlasTypingIndicator) findViewById(R.id.atlas_screen_messages_typing_indicator);
    typingIndicator.init(conv,
            new AtlasTypingIndicator.DefaultTypingIndicatorCallback(app.getParticipantProvider()));

    // location manager for inserting locations:
    this.locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);

    prepareActionBar();
}

From source file:com.grupohqh.carservices.operator.ManipulateCarActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manipulate_car);

    if (getIntent().getExtras().containsKey("userId"))
        userId = getIntent().getExtras().getInt("userId");
    if (getIntent().getExtras().containsKey("carOwnerId"))
        carOwnerId = getIntent().getExtras().getInt("carOwnerId");

    CARBRAND_URL = getString(R.string.base_url) + getString(R.string.carbrands_url);
    CARLINE_URL = getString(R.string.base_url) + getString(R.string.carmodels_url);
    SAVECAR_URL = getString(R.string.base_url) + "savecar/";
    SAVEPHOTO_URL = getString(R.string.base_url) + "savephoto/";
    hasCamera = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY);

    etTagNumber = (EditText) findViewById(R.id.etTagNumber);
    etUsernameOwner = (EditText) findViewById(R.id.etUsernameOwner);
    etCarBrand = (EditText) findViewById(R.id.etCarBrand);
    etCarModel = (EditText) findViewById(R.id.etCarModel);
    etCarYear = (EditText) findViewById(R.id.etCarYear);
    etColor = (EditText) findViewById(R.id.etCarColor);
    etSerialNumber = (EditText) findViewById(R.id.etSerialNumber);
    etLicensePlate = (EditText) findViewById(R.id.etLicensePlate);
    etKM = (EditText) findViewById(R.id.etKm);
    imgCar = (ImageView) findViewById(R.id.imgCar);
    spCarBrand = (Spinner) findViewById(R.id.spCarBrand);
    spCarModel = (Spinner) findViewById(R.id.spCarModel);
    btnSaveCar = (Button) findViewById(R.id.btnSaveCar);
    btnTakePicture = (Button) findViewById(R.id.btnTakePicture);
    bar = (ProgressBar) findViewById(R.id.progressBar);
    viewUsername = findViewById(R.id.viewUsername);

    if (savedInstanceState != null) {
        bm = savedInstanceState.getParcelable("bm");
        if (bm != null)
            imgCar.setImageBitmap(bm);/*from w  ww  .j a v a 2  s. c o  m*/
    }

    bar.setVisibility(View.GONE);
    etCarBrand.setVisibility(View.GONE);
    etCarModel.setVisibility(View.GONE);
    viewUsername.setVisibility(carOwnerId == 0 ? View.VISIBLE : View.GONE);

    btnTakePicture.setEnabled(hasCamera);
    btnTakePicture.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTempFile(ManipulateCarActivity.this)));
            startActivityForResult(intent, CAPTURE_IMAGE);
        }
    });

    btnSaveCar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (validate())
                new SaveCarAsyncTask().execute(SAVECAR_URL);
        }
    });

    spCarBrand.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0)
                ((TextView) parent.getChildAt(position)).setTextColor(Color.GRAY);
            if (mapBrands.get(brands.get(position)) == otherId) {
                etCarBrand.setVisibility(View.VISIBLE);
                etCarModel.setVisibility(View.VISIBLE);
                spCarModel.setVisibility(View.GONE);
                etCarBrand.requestFocus();
            } else {
                etCarBrand.setVisibility(View.GONE);
                etCarModel.setVisibility(View.GONE);
                spCarModel.setVisibility(View.VISIBLE);
                new LoadCarModelsAsyncTask().execute(CARLINE_URL + mapBrands.get(brands.get(position)) + "/");
                reload = true;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    spCarModel.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (position == 0)
                ((TextView) parent.getChildAt(position)).setTextColor(Color.GRAY);
            if (mapModels.get(models.get(position)) == otherId) {
                etCarModel.setVisibility(View.VISIBLE);
                etCarModel.requestFocus();
            } else {
                etCarModel.setVisibility(View.GONE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });

    if (useMiniMe) {
        manager = (UsbManager) getSystemService(Context.USB_SERVICE);
        usbCommunication = UsbCommunication.newInstance();

        IntentFilter filter = new IntentFilter();
        filter.addAction(UsbManager.ACTION_USB_DEVICE_ATTACHED); // will intercept by system
        filter.addAction(UsbManager.ACTION_USB_DEVICE_DETACHED);
        filter.addAction(ACTION_USB_PERMISSION);
        registerReceiver(usbReceiver, filter);

        etEPC = (EditText) findViewById(R.id.etEPC);
        btnReadTAG = (Button) findViewById(R.id.btnReadTAG);
        txtStatus = (TextView) findViewById(R.id.txtStatus);
        btnReadTAG.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                etEPC.setText("");
                if (txtStatus.getText().toString().equals("conectado")) {
                    readTag();
                } else {
                    Toast.makeText(getBaseContext(), "dispositivo " + txtStatus.getText(), Toast.LENGTH_LONG)
                            .show();
                }
            }
        });
    }

    etKM.addTextChangedListener(new NumberTextWatcher(etKM));
}

From source file:com.example.shinelon.ocrcamera.MainActivity.java

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
    //???// w ww.  j av a  2s  . c om
    case REQUEST_CAMERA:
        if (resultCode == RESULT_OK) {
            //??????
            Intent intent = new Intent("com.android.camera.action.CROP");
            intent.setDataAndType(mUri, "image/*");
            intent.putExtra(MediaStore.EXTRA_OUTPUT, mUri);
            startActivityForResult(intent, CAMERA_CROP);
        }
        break;
    //??
    case CAMERA_CROP:
        if (resultCode == RESULT_OK) {
            setImage(mUri);
            mCropButton.setEnabled(true);
        }
        break;
    case SELECT:
        if (data != null) {
            Uri uri = data.getData();
            crop(uri);
        }
        break;
    case CROP:
        break;
    default:
        break;
    }

}

From source file:com.hackaton.NuevaQuejaActivity.java

@AfterPermissionGranted(RC_CAMERA_PERMISSIONS)
private void showImagePicker() {
    // Check for camera permissions
    Log.d(TAG, "launchCamera");

    // Check that we have permission to read images from external storage.
    String perm = Manifest.permission.READ_EXTERNAL_STORAGE;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && !EasyPermissions.hasPermissions(this, perm)) {
        EasyPermissions.requestPermissions(this,
                "This sample reads images from your camera to demonstrate uploading.", RC_STORAGE_PERMS, perm);
        return;/*from   www  .j  ava  2 s .  com*/
    }

    // Create intent
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    // Choose file storage location
    File file = new File(Environment.getExternalStorageDirectory(), UUID.randomUUID().toString() + ".jpg");
    mFileUri = Uri.fromFile(file);
    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, mFileUri);

    // Launch intent
    startActivityForResult(takePictureIntent, RC_TAKE_PICTURE);
}

From source file:info.guardianproject.iocipher.camera.VideoCameraActivity.java

private void startRecording() {
    mFrameQ = new ArrayDeque<VideoFrame>();

    mFramesTotal = 0;/*from   ww w  .  j av a  2s. c  o m*/
    mFpsCounter = 0;

    lastTime = System.currentTimeMillis();

    String fileName = "secure_video_" + new java.util.Date().getTime() + ".mp4";
    fileOut = new info.guardianproject.iocipher.File(mFileBasePath, fileName);

    mResultList.add(fileOut.getAbsolutePath());
    Intent intentResult = new Intent().putExtra(MediaStore.EXTRA_OUTPUT,
            mResultList.toArray(new String[mResultList.size()]));
    setResult(Activity.RESULT_OK, intentResult);

    try {
        mIsRecording = true;

        if (useAAC)
            initAudio(fileOut.getAbsolutePath() + ".aac");
        else
            initAudio(fileOut.getAbsolutePath() + ".pcm");

        boolean withEmbeddedAudio = true;

        Encoder encoder = new Encoder(fileOut, mFPS, withEmbeddedAudio);
        encoder.start();
        //start capture
        startAudioRecording();

        progress.setText(R.string._rec_);

    } catch (Exception e) {
        Log.d("Video", "error starting video", e);
        Toast.makeText(this, "Error init'ing video: " + e.getLocalizedMessage(), Toast.LENGTH_LONG).show();
        finish();
    }
}

From source file:com.android.browser.UploadHandler.java

private Intent createCameraIntent(Uri contentUri) {
    if (contentUri == null)
        throw new IllegalArgumentException();
    mCapturedMedia = contentUri;//from  www  .jav  a 2 s  . c o m
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedMedia);
    intent.setClipData(ClipData.newUri(mController.getActivity().getContentResolver(), FILE_PROVIDER_AUTHORITY,
            mCapturedMedia));
    return intent;
}

From source file:de.enlightened.peris.ProfileFragment.java

private void setupElements() {
    this.tvCreated = (TextView) this.activity.findViewById(R.id.profileCreated);
    this.tvPostCount = (TextView) this.activity.findViewById(R.id.profilePostCount);
    this.tvActivity = (TextView) this.activity.findViewById(R.id.profileLastActivity);
    this.tvTagline = (TextView) this.activity.findViewById(R.id.profileTagline);
    this.tvAbout = (TextView) this.activity.findViewById(R.id.profileAbout);
    this.ivProfilePic = (ImageView) this.activity.findViewById(R.id.profilePicture);

    final String userid = this.application.getSession().getServer().serverUserId;
    final LinearLayout avatarButtons = (LinearLayout) this.activity
            .findViewById(R.id.profile_avatar_editor_buttons);

    if (this.userId == null) {
        avatarButtons.setVisibility(View.GONE);
    } else if (!this.userId.equals(userid)) {
        avatarButtons.setVisibility(View.GONE);
    }// w ww. j a v  a2 s. co m

    final Button btnPicFromCamera = (Button) this.activity.findViewById(R.id.profile_upload_avatar_camera);
    final Button btnPicFromGallery = (Button) this.activity.findViewById(R.id.profile_upload_avatar_gallery);
    if (!this.canHandleCameraIntent()) {
        btnPicFromCamera.setVisibility(View.GONE);
    }
    btnPicFromGallery.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            final Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, "Select Picture"), GALLERY_PIC_REQUEST);
        }
    });

    btnPicFromCamera.setOnClickListener(new View.OnClickListener() {
        public void onClick(final View v) {
            final Intent imageIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            final File imagesFolder = new File(Environment.getExternalStorageDirectory(), "temp");
            imagesFolder.mkdirs();
            final File image = new File(imagesFolder, "temp.jpg");
            final Uri uriSavedImage = Uri.fromFile(image);
            imageIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
            startActivityForResult(imageIntent, CAMERA_PIC_REQUEST);
        }
    });

}