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.intel.xdk.camera.Camera.java

public synchronized void takePicture(final int quality, final String saveToLibYN, final String picType) {
    //saveToLibYN is not used because the camera activity always saves to gallery

    PackageManager pm = activity.getPackageManager();
    if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA) == false) {
        fireJSEvent("camera.picture.add", false, null,
                new String[] { String.format("ev.error='device has no camera';") });
    }//from  ww w.j av a 2  s  .  c  o m

    if (busy) {
        cameraBusy();
    }
    this.busy = true;

    File outputFile = new File(Environment.getExternalStorageDirectory(), "test." + picType);

    //put required info in shared prefs
    SharedPreferences.Editor prefsEditor = activity.getSharedPreferences(cameraPrefsKey, 0).edit();
    prefsEditor.putString(cameraPrefsFileName, outputFile.getAbsolutePath());
    prefsEditor.putBoolean(cameraPrefsIsPNG, "png".equalsIgnoreCase(picType));
    prefsEditor.putInt(cameraPrefsQuality, quality);
    prefsEditor.commit();

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outputFile));

    //cordova.setActivityResultCallback(this);
    // TODO: figure this out
    cordova.startActivityForResult(this, intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    //activity.setLaunchedChildActivity(true);
    //activity.startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}

From source file:it.rignanese.leo.slimtwitter.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // setup the sharedPreferences
    savedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    setContentView(R.layout.activity_main);

    //setup the floating button
    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override//  w  w w . j a  v  a  2 s.c om
        public void onClick(View view) {
            webViewTwitter.scrollTo(0, 0);//scroll up
        }
    });

    // setup the refresh layout
    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.swipe_container);
    swipeRefreshLayout.setColorSchemeResources(R.color.officialAzureTwitter, R.color.darkAzureSlimTwitterTheme);// set the colors
    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refreshPage();//reload the page
            swipeRefresh = true;
        }
    });

    // setup the webView
    webViewTwitter = (WebView) findViewById(R.id.webView);
    setUpWebViewDefaults(webViewTwitter);//set the settings

    goHome();//load homepage

    //WebViewClient that is the client callback.
    webViewTwitter.setWebViewClient(new WebViewClient() {//advanced set up

        // when there isn't a connetion
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            String summary = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><h1 "
                    + "style='text-align:center; padding-top:15%;'>" + getString(R.string.titleNoConnection)
                    + "</h1> <h3 style='text-align:center; padding-top:1%; font-style: italic;'>"
                    + getString(R.string.descriptionNoConnection)
                    + "</h3>  <h5 style='text-align:center; padding-top:80%; opacity: 0.3;'>"
                    + getString(R.string.awards) + "</h5></body></html>";
            webViewTwitter.loadData(summary, "text/html; charset=utf-8", "utf-8");//load a custom html page

            noConnectionError = true;
            swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing
        }

        // when I click in a external link
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            if (url == null || url.contains("twitter.com")) {
                //url is ok
                return false;
            } else {
                //if the link doesn't contain 'twitter.com', open it using the browser
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
                return true;
            }
        }

        //START management of loading
        @Override
        public void onPageFinished(WebView view, String url) {
            swipeRefreshLayout.setRefreshing(false); //when the page is loaded, stop the refreshing
            super.onPageFinished(view, url);
        }
        //END management of loading

    });

    //WebChromeClient for handling all chrome functions.
    webViewTwitter.setWebChromeClient(new WebChromeClient() {
        //to upload files
        //thanks to gauntface
        //https://github.com/GoogleChrome/chromium-webview-samples
        public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
                WebChromeClient.FileChooserParams fileChooserParams) {
            if (mFilePathCallback != null) {
                mFilePathCallback.onReceiveValue(null);
            }
            mFilePathCallback = filePathCallback;

            Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            if (takePictureIntent.resolveActivity(getBaseContext().getPackageManager()) != null) {
                // Create the File where the photo should go
                File photoFile = null;
                try {
                    photoFile = createImageFile();
                    takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
                } catch (IOException ex) {
                    // Error occurred while creating the File
                }

                // Continue only if the File was successfully created
                if (photoFile != null) {
                    mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
                    takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile));
                } else {
                    takePictureIntent = null;
                }
            }

            Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
            contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
            contentSelectionIntent.setType("image/*");

            Intent[] intentArray;
            if (takePictureIntent != null) {
                intentArray = new Intent[] { takePictureIntent };
            } else {
                intentArray = new Intent[0];
            }

            Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
            chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
            chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
            chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);

            startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);

            return true;
        }
    });
}

From source file:br.com.brolam.cloudvision.ui.helpers.ImagesHelper.java

/**
 * Realizar uma requisio de uma foto na camera fotogrfica nativa do Android para uma imagem
 * de background Note Vision.//  w  w  w.  ja v a  2  s.  com
 * @param noteVisionKey informar uma chave vlida.
 * @throws IOException
 */
public void takeNoteVisionBackground(String noteVisionKey) throws IOException {
    Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {
        //Informar o arquivo temporrio onde a imagem ser gravada.
        takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, getImageUriFileProvider(noteVisionKey));
        //Informar a chave do Note Vision que ser recuperado no mtodo {@see saveNoteVisionBackground}
        requestImageNoteVisionKey = noteVisionKey;
        activity.startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE);
    }
}

From source file:com.chute.android.photopickerplus.ui.activity.ServicesActivity.java

@Override
public void recordVideo() {
    Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    Uri uri = AppUtil.getTempVideoFile();
    if (uri != null) {
        intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    }//ww  w  . jav a 2  s.co m
    intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
    startActivityForResult(intent, Constants.CAMERA_VIDEO_REQUEST);

}

From source file:com.cw.litenote.note_add.Note_addCameraVideo.java

private void takeVideoWithName() {
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);

    // Ensure that there's a camera activity to handle the intent
    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        // Create temporary image File where the photo will save in
        File tempFile = null;//from  w ww  .  ja v a  2 s.co m
        try {
            tempFile = createTempVideoFile();
        } catch (IOException ex) {
            // Error occurred while creating the File
        }

        // Continue only if the File was successfully created
        if (tempFile != null) {
            videoUri = Uri.fromFile(tempFile); // so far, file size is 0
            takeVideoIntent.putExtra(MediaStore.EXTRA_OUTPUT, videoUri); // appoint Uri for captured image
            videoUriInDB = videoUri.toString();
            startActivityForResult(takeVideoIntent, TAKE_VIDEO_ACT);
        }
    }
}

From source file:com.app.imagecreator.activities.HomeActivity.java

private void loadFromCamera() {

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    ContentValues contentValues = new ContentValues();
    outputFileUri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);

    startActivityForResult(intent, FETCH_FROM_CAMERA_FULLVIEW);

}

From source file:ca.ualberta.app.activity.CreateQuestionActivity.java

/**
 * Create a storage for the picture in the question
 * /*from   w  ww .  jav  a2  s  .c  o  m*/
 * @param view
 *            View passed to the activity to check which button was pressed.
 */
public void take_question_pic(View view) {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    // Create a folder to store pictures
    String folder = Environment.getExternalStorageDirectory().getAbsolutePath() + "/tmp";
    File folderF = new File(folder);
    if (!folderF.exists()) {
        folderF.mkdir();
    }

    // Create an URI for the picture file
    String imageFilePath = folder + "/" + String.valueOf(System.currentTimeMillis()) + ".jpg";
    File imageFile = new File(imageFilePath);
    imageFileUri = Uri.fromFile(imageFile);
    intent.putExtra(MediaStore.EXTRA_OUTPUT, imageFileUri);

    startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);

}

From source file:de.skubware.opentraining.activity.create_exercise.ImageFragment.java

private void dispatchTakePictureIntent() {
    Intent takePictureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

    // Ensure that there's a camera activity to handle the intent
    if (takePictureIntent.resolveActivity(getActivity().getPackageManager()) != null) {
        try {//  ww  w .  j  ava 2 s. c om
            mTempImageUri = createImageFile(false);
        } catch (IOException ex) {
            // Error occurred while creating the File
            Log.e(TAG, "Error creating image file", ex);
        }
        takePictureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mTempImageUri);
        startActivityForResult(takePictureIntent, CreateExerciseActivity.TAKE_PICTURE);
    } else {
        Log.e(TAG, "No camera activity for handling camera intent");
    }
}

From source file:com.akalizakeza.apps.ishusho.activity.NewPostActivity.java

@AfterPermissionGranted(RC_CAMERA_PERMISSIONS)
private void showImagePicker() {
    // Check for camera permissions
    if (!EasyPermissions.hasPermissions(this, cameraPerms)) {
        EasyPermissions.requestPermissions(this, "This sample will upload a picture from your Camera",
                RC_CAMERA_PERMISSIONS, cameraPerms);
        return;//from  www  .  java2  s  .c  o  m
    }

    // Choose file storage location
    File file = new File(getExternalCacheDir(), UUID.randomUUID().toString());
    mFileUri = Uri.fromFile(file);

    // Camera
    final List<Intent> cameraIntents = new ArrayList<Intent>();
    final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    final PackageManager packageManager = getPackageManager();
    final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0);
    for (ResolveInfo res : listCam) {
        final String packageName = res.activityInfo.packageName;
        final Intent intent = new Intent(captureIntent);
        intent.setComponent(new ComponentName(packageName, res.activityInfo.name));
        intent.setPackage(packageName);
        intent.putExtra(MediaStore.EXTRA_OUTPUT, mFileUri);
        cameraIntents.add(intent);
    }

    // Image Picker
    Intent pickerIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

    Intent chooserIntent = Intent.createChooser(pickerIntent, getString(R.string.picture_chooser_title));
    chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
            cameraIntents.toArray(new Parcelable[cameraIntents.size()]));
    startActivityForResult(chooserIntent, TC_PICK_IMAGE);
}

From source file:com.dycody.android.idealnote.CategoryActivity.java

public void save(Bitmap bitmap) {
    if (bitmap == null) {
        setResult(RESULT_CANCELED);/*from w  w  w.  j  a va  2  s  .co  m*/
        super.finish();
    }

    try {
        Uri uri = getIntent().getParcelableExtra(MediaStore.EXTRA_OUTPUT);
        File bitmapFile = new File(uri.getPath());
        FileOutputStream out = new FileOutputStream(bitmapFile);
        assert bitmap != null;
        bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);

        if (bitmapFile.exists()) {
            Intent localIntent = new Intent().setData(Uri.fromFile(bitmapFile));
            setResult(RESULT_OK, localIntent);
        } else {
            setResult(RESULT_CANCELED);
        }
        super.finish();

    } catch (Exception e) {
        Log.d(Constants.TAG, "Bitmap not found", e);
    }
}