Example usage for android.provider MediaStore ACTION_IMAGE_CAPTURE

List of usage examples for android.provider MediaStore ACTION_IMAGE_CAPTURE

Introduction

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

Prototype

String ACTION_IMAGE_CAPTURE

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

Click Source Link

Document

Standard Intent action that can be sent to have the camera application capture an image and return it.

Usage

From source file:au.org.ala.fielddata.mobile.CollectSurveyData.java

/**
 * Launches the default camera application to take a photo and store the
 * result for the supplied attribute./* w  w w .  j  a  va2 s  .c  om*/
 * 
 * @param attribute
 *            the attribute the photo relates to.
 */
public void takePhoto(Attribute attribute) {
    if (StorageManager.canWriteToExternalStorage()) {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        Uri fileUri = StorageManager.getOutputMediaFileUri(StorageManager.MEDIA_TYPE_IMAGE);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
        // Unfortunately, this URI isn't being returned in the
        // result as expected so we have to save it somewhere it can
        // survive an activity restart.
        surveyViewModel.setTempValue(attribute, fileUri.toString());
        startActivityForResult(intent, CollectSurveyData.TAKE_PHOTO_REQUEST);
    } else {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Cannot take photo")
                .setMessage("Please ensure you have mounted your SD card and it is writable")
                .setPositiveButton("OK", null).show();
    }
}

From source file:info.papdt.blacklight.ui.statuses.NewPostActivity.java

private void showPicturePicker() {
    new AlertDialog.Builder(this).setItems(getResources().getStringArray(R.array.picture_picker_array),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialogInterface, int id) {
                    switch (id) {
                    case 0:
                        Intent i = new Intent();
                        if (Build.VERSION.SDK_INT >= 19) {
                            i.setAction(Intent.ACTION_OPEN_DOCUMENT);
                            i.addCategory(Intent.CATEGORY_OPENABLE);
                            i.setType("image/*");
                        } else {
                            i.setAction(Intent.ACTION_PICK);
                            i.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                        }// w ww . java2s  .  co  m
                        startActivityForResult(i, REQUEST_PICK_IMG);
                        break;
                    case 1:
                        Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
                        Uri uri = Utility.getOutputMediaFileUri();
                        captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
                        startActivityForResult(captureIntent, REQUEST_CAPTURE_PHOTO);
                        break;
                    case 2:
                        Intent multi = new Intent();
                        multi.setAction("us.shandian.blacklight.MULTI_PICK");
                        multi.setClass(NewPostActivity.this, MultiPicturePicker.class);
                        startActivityForResult(multi, 1000);
                        break;
                    }
                }
            }).show();
}

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

private void captureImageFromCamera() {
    mCurrentPhotoUri = getImageUri();/*  w ww  .ja va2  s  .  com*/
    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:com.rsmsa.accapp.MainActivity.java

/**
 * Capturing Camera Image will lauch camera app requrest image capture
 *///ww  w  .j a va 2s.  c  o  m
private void captureImage() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);

    // start the image capture Intent
    startActivityForResult(intent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE);
}

From source file:com.ushahidi.android.app.ui.phone.AddReportActivity.java

/**
 * Create various dialog/*from   w  ww . j  a v  a 2s .co m*/
 */
@Override
protected Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_ERROR_NETWORK: {
        AlertDialog dialog = (new AlertDialog.Builder(this)).create();
        dialog.setTitle(getString(R.string.network_error));
        dialog.setMessage(getString(R.string.network_error_msg));
        dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.setCancelable(false);
        return dialog;
    }
    case DIALOG_ERROR_SAVING: {
        AlertDialog dialog = (new AlertDialog.Builder(this)).create();
        dialog.setTitle(getString(R.string.network_error));
        dialog.setMessage(getString(R.string.file_system_error_msg));
        dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.setCancelable(false);
        return dialog;
    }

    case DIALOG_CHOOSE_IMAGE_METHOD: {

        AlertDialog dialog = (new AlertDialog.Builder(this)).create();
        dialog.setTitle(getString(R.string.choose_method));
        dialog.setMessage(getString(R.string.how_to_select_pic));
        dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_PICK);
                intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                startActivityForResult(intent, REQUEST_CODE_IMAGE);
                dialog.dismiss();
            }
        });
        dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                intent.putExtra(MediaStore.EXTRA_OUTPUT,
                        PhotoUtils.getPhotoUri(photoName, AddReportActivity.this));
                startActivityForResult(intent, REQUEST_CODE_CAMERA);
                dialog.dismiss();
            }
        });

        dialog.setCancelable(false);
        return dialog;
    }

    case DIALOG_MULTIPLE_CATEGORY: {
        if (showCategories() != null) {
            return new AlertDialog.Builder(this).setTitle(R.string.choose_categories)
                    .setMultiChoiceItems(showCategories(), setCheckedCategories(),
                            new DialogInterface.OnMultiChoiceClickListener() {
                                public void onClick(DialogInterface dialog, int whichButton,
                                        boolean isChecked) {
                                    // see if categories have previously

                                    if (isChecked) {
                                        mVectorCategories.add(mCategoriesId.get(whichButton));

                                        mError = false;
                                    } else {
                                        mVectorCategories.remove(mCategoriesId.get(whichButton));
                                    }

                                    setSelectedCategories(mVectorCategories);
                                }
                            })
                    .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {

                            /* User clicked Yes so do some stuff */
                        }
                    }).create();
        }
    }

    case TIME_DIALOG_ID:
        return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR),
                mCalendar.get(Calendar.MINUTE), false);

    case DATE_DIALOG_ID:
        return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR),
                mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH));

    case DIALOG_SHOW_MESSAGE:
        AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this);
        messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

        AlertDialog showDialog = messageBuilder.create();
        showDialog.show();
        break;

    case DIALOG_SHOW_REQUIRED:
        AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this);
        requiredBuilder.setTitle(R.string.required_fields);
        requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });

        AlertDialog showRequiredDialog = requiredBuilder.create();
        showRequiredDialog.show();
        break;

    // prompt for unsaved changes
    case DIALOG_SHOW_PROMPT: {
        AlertDialog dialog = (new AlertDialog.Builder(this)).create();
        dialog.setTitle(getString(R.string.unsaved_changes));
        dialog.setMessage(getString(R.string.want_to_cancel));
        dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();
            }
        });
        dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                finish();
                dialog.dismiss();
            }
        });

        dialog.setCancelable(false);
        return dialog;
    }

    // prompt for report deletion
    case DIALOG_SHOW_DELETE_PROMPT: {
        AlertDialog dialog = (new AlertDialog.Builder(this)).create();
        dialog.setTitle(getString(R.string.delete_report));
        dialog.setMessage(getString(R.string.want_to_delete));
        dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                dialog.dismiss();
            }
        });
        dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                // delete report
                deleteReport();
                dialog.dismiss();
            }
        });

        dialog.setCancelable(false);
        return dialog;
    }

    }
    return null;
}

From source file:org.dicadeveloper.runnerapp.TrackDetailActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    Intent intent;/*  w  w  w  .  j av a2  s  . c  o  m*/
    switch (item.getItemId()) {
    case R.id.track_detail_insert_marker:
        AnalyticsUtils.sendPageViews(this, AnalyticsUtils.ACTION_INSERT_MARKER);
        intent = IntentUtils.newIntent(this, MarkerEditActivity.class)
                .putExtra(MarkerEditActivity.EXTRA_TRACK_ID, trackId);
        startActivity(intent);
        return true;
    case R.id.track_detail_insert_photo:
        if (!FileUtils.isExternalStorageWriteable()) {
            Toast.makeText(this, R.string.external_storage_not_writable, Toast.LENGTH_LONG).show();
            return false;
        }

        File dir = FileUtils.getPhotoDir(trackId);
        FileUtils.ensureDirectoryExists(dir);

        String fileName = SimpleDateFormat.getDateTimeInstance().format(new Date());
        File file = new File(dir, FileUtils.buildUniqueFileName(dir, fileName, JPEG_EXTENSION));

        photoUri = Uri.fromFile(file);
        intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE).putExtra(MediaStore.EXTRA_OUTPUT, photoUri);
        startActivityForResult(intent, CAMERA_REQUEST_CODE);
        return true;
    case R.id.track_detail_play:
        playTracks(new long[] { trackId });
        return true;
    case R.id.track_detail_share:
        shareTrack(trackId);
        return true;
    case R.id.track_detail_markers:
        intent = IntentUtils.newIntent(this, MarkerListActivity.class)
                .putExtra(MarkerListActivity.EXTRA_TRACK_ID, trackId);
        startActivity(intent);
        return true;
    case R.id.track_detail_play_multiple:
        PlayMultipleDialogFragment.newInstance(trackId).show(getSupportFragmentManager(),
                PlayMultipleDialogFragment.PLAY_MULTIPLE_DIALOG_TAG);
        return true;
    case R.id.track_detail_voice_frequency:
        FrequencyDialogFragment
                .newInstance(R.string.voice_frequency_key, PreferencesUtils.VOICE_FREQUENCY_DEFAULT,
                        R.string.menu_voice_frequency)
                .show(getSupportFragmentManager(), FrequencyDialogFragment.FREQUENCY_DIALOG_TAG);
        return true;
    case R.id.track_detail_split_frequency:
        FrequencyDialogFragment
                .newInstance(R.string.split_frequency_key, PreferencesUtils.SPLIT_FREQUENCY_DEFAULT,
                        R.string.menu_split_frequency)
                .show(getSupportFragmentManager(), FrequencyDialogFragment.FREQUENCY_DIALOG_TAG);
        return true;
    case R.id.track_detail_export:
        Track track = myTracksProviderUtils.getTrack(trackId);
        boolean hideDrive = track != null ? track.isSharedWithMe() : true;
        ExportDialogFragment.newInstance(hideDrive).show(getSupportFragmentManager(),
                ExportDialogFragment.EXPORT_DIALOG_TAG);
        return true;
    case R.id.track_detail_edit:
        intent = IntentUtils.newIntent(this, TrackEditActivity.class).putExtra(TrackEditActivity.EXTRA_TRACK_ID,
                trackId);
        startActivity(intent);
        return true;
    case R.id.track_detail_delete:
        deleteTracks(new long[] { trackId });
        return true;
    case R.id.track_detail_sensor_state:
        intent = IntentUtils.newIntent(this, SensorStateActivity.class);
        startActivity(intent);
        return true;
    case R.id.track_detail_settings:
        intent = IntentUtils.newIntent(this, SettingsActivity.class);
        startActivity(intent);
        return true;
    case R.id.track_detail_help_feedback:
        intent = IntentUtils.newIntent(this, HelpActivity.class);
        startActivity(intent);
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

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

private void show2Dialog(int type) {

    AlertDialog.Builder builder = new AlertDialog.Builder(MerchantEdit.this);
    final String[] items = getResources().getStringArray(R.array.apply_detail_upload);

    MerchantEdit.this.type = type;

    builder.setItems(items, new DialogInterface.OnClickListener() {
        @Override// www  .  j  a  va2 s .c o m
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {

            case 0: {

                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 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(MerchantEdit.this, getString(R.string.toast_no_sdcard));
                }
                break;
            }
            }
        }
    });

    builder.show();
}

From source file:com.givon.anhao.activity.AnhaoMainActivity.java

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

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

From source file:org.gots.ui.TabSeedActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle item selection
    Intent i;//from  www.j  a v a  2  s  .  co m
    switch (item.getItemId()) {
    case android.R.id.home:
        finish();
        return true;
    case R.id.help:
        Intent browserIntent = new Intent(this, WebHelpActivity.class);
        browserIntent.putExtra(WebHelpActivity.URL, getClass().getSimpleName());
        startActivity(browserIntent);
        return true;

    case R.id.sow:
        Intent intent = new Intent(this, MyMainGarden.class);
        intent.putExtra(MyMainGarden.SELECT_ALLOTMENT, true);
        intent.putExtra(MyMainGarden.VENDOR_SEED_ID, mSeed.getSeedId());
        startActivity(intent);
        return true;
    case R.id.planning:
        FragmentManager fm = getSupportFragmentManager();
        DialogFragment scheduleDialog = new ScheduleActionFragment();
        Bundle data = new Bundle();
        data.putInt(GOTS_GROWINGSEED_ID, mSeed.getGrowingSeedId());
        scheduleDialog.setArguments(data);
        scheduleDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);
        scheduleDialog.show(fm, "fragment_planning");
        return true;
    case R.id.download:
        new AsyncTask<Void, Integer, File>() {
            boolean licenceAvailable = false;

            IabHelper buyHelper;

            private ProgressDialog dialog;

            protected void onPreExecute() {
                licenceAvailable = gotsPurchase.getFeatureExportPDF() ? true : gotsPurchase.isPremium();
                dialog = ProgressDialog.show(TabSeedActivity.this, "",
                        getResources().getString(R.string.gots_loading), true);
                dialog.setCanceledOnTouchOutside(true);
            };

            @Override
            protected File doInBackground(Void... params) {
                if (licenceAvailable)
                    try {
                        GotsActionSeedProvider provider = GotsActionSeedManager.getInstance()
                                .initIfNew(getApplicationContext());
                        return provider.downloadHistory(mSeed);
                    } catch (GotsServerRestrictedException e) {
                        Log.w(TAG, e.getMessage());
                        licenceAvailable = false;
                        return null;
                    }
                return null;
            }

            @Override
            protected void onPostExecute(File result) {
                try {
                    dialog.dismiss();
                    dialog = null;
                } catch (Exception e) {
                    // nothing
                }
                if (!gotsPrefs.isConnectedToServer()) {
                    AlertDialog.Builder builder = new AlertDialog.Builder(TabSeedActivity.this);
                    builder.setMessage(getResources().getString(R.string.login_connect_restricted))
                            .setCancelable(false)
                            .setPositiveButton(getResources().getString(R.string.login_connect),
                                    new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int id) {
                                            LoginDialogFragment dialogFragment = new LoginDialogFragment();
                                            dialogFragment.show(getSupportFragmentManager(), "");
                                        }
                                    })
                            .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {
                                    dialog.cancel();
                                }
                            });
                    builder.show();
                }
                if (!licenceAvailable) {
                    FragmentManager fm = getSupportFragmentManager();
                    GotsBillingDialog editNameDialog = new GotsBillingDialog(
                            GotsPurchaseItem.SKU_FEATURE_PDFHISTORY);
                    editNameDialog.setStyle(DialogFragment.STYLE_NORMAL, R.style.CustomDialog);

                    editNameDialog.show(fm, "fragment_edit_name");
                }
                if (result != null) {
                    Intent pdfIntent = new Intent(Intent.ACTION_VIEW);
                    pdfIntent.setDataAndType(Uri.fromFile(result), "application/pdf");
                    startActivity(pdfIntent);
                }

            }
        }.execute();

        return true;
    case R.id.photo:
        photoAction = new PhotoAction(getApplicationContext());
        Date now = new Date();
        cameraPicture = new File(photoAction.getImageFile(now).getAbsolutePath());
        Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(cameraPicture));
        // takePictureIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivityForResult(takePictureIntent, PICK_IMAGE);

        return true;
    case R.id.delete:
        final DeleteAction deleteAction = new DeleteAction(this);

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(this.getResources().getString(R.string.action_delete_seed)).setCancelable(false)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        new AsyncTask<SeedActionInterface, Integer, Void>() {
                            @Override
                            protected Void doInBackground(SeedActionInterface... params) {
                                SeedActionInterface actionItem = params[0];
                                actionItem.execute(mSeed);
                                return null;
                            }

                            @Override
                            protected void onPostExecute(Void result) {
                                Toast.makeText(getApplicationContext(), "action done", Toast.LENGTH_SHORT)
                                        .show();
                                TabSeedActivity.this.finish();
                                super.onPostExecute(result);
                            }
                        }.execute(deleteAction);
                        sendBroadcast(new Intent(BroadCastMessages.GROWINGSEED_DISPLAYLIST));
                        dialog.dismiss();
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
        builder.show();
        return true;
    case R.id.workflow:
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                NuxeoWorkflowProvider nuxeoWorkflowProvider = new NuxeoWorkflowProvider(
                        getApplicationContext());
                //                    BaseSeedInterface baseSeedInterface = (BaseSeedInterface) arg0.getItemAtPosition(arg2);
                nuxeoWorkflowProvider.startWorkflowValidation(mSeed);
                return null;
            }
        }.execute();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.dazone.crewchat.libGallery.activity.HomeFragmentActivity.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.cameraImageViewFromMediaChooserHeaderBar:
        if (v.getTag().toString().equals(getResources().getString(R.string.video))) {
            Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_VIDEO); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_VIDEO_ACTIVITY_REQUEST_CODE);

        } else {/*  w  ww.  j  ava  2s.c o  m*/
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            fileUri = getOutputMediaFileUri(MediaChooserConstants.MEDIA_TYPE_IMAGE); // create a file to save the image
            intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name

            // start the image capture Intent
            startActivityForResult(intent, MediaChooserConstants.CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
        }
        break;
    case R.id.doneTextViewViewFromMediaChooserHeaderView:
        FragmentManager fragmentManager = getSupportFragmentManager();
        ImageFragment imageFragment = (ImageFragment) fragmentManager.findFragmentByTag("tab1");
        VideoFragment videoFragment = (VideoFragment) fragmentManager.findFragmentByTag("tab2");

        if (videoFragment != null || imageFragment != null) {

            if (videoFragment != null) {
                if (videoFragment.getSelectedVideoList() != null
                        && videoFragment.getSelectedVideoList().size() > 0) {
                    Intent videoIntent = new Intent();
                    videoIntent.setAction(MediaChooser.VIDEO_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    videoIntent.putStringArrayListExtra("list", videoFragment.getSelectedVideoList());
                    sendBroadcast(videoIntent);
                } else {
                    Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
            }

            if (imageFragment != null) {
                if (imageFragment.getSelectedImageList() != null
                        && imageFragment.getSelectedImageList().size() > 0) {
                    Intent imageIntent = new Intent();
                    imageIntent.setAction(MediaChooser.IMAGE_SELECTED_ACTION_FROM_MEDIA_CHOOSER);
                    imageIntent.putStringArrayListExtra("list", imageFragment.getSelectedImageList());
                    sendBroadcast(imageIntent);
                } else {
                    Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                            Toast.LENGTH_SHORT).show();
                    return;
                }
            }
            if (BucketHomeFragmentActivity.Instance != null) {
                BucketHomeFragmentActivity.Instance.finish();
            }
            finish();
        } else {
            Toast.makeText(HomeFragmentActivity.this, getString(R.string.please_select_file),
                    Toast.LENGTH_SHORT).show();
        }
        break;
    case R.id.backArrowImageViewFromMediaChooserHeaderView:
        finish();
        break;
    default:
        break;
    }
}