List of usage examples for android.provider MediaStore EXTRA_OUTPUT
String EXTRA_OUTPUT
To view the source code for android.provider MediaStore EXTRA_OUTPUT.
Click Source Link
From source file:info.shibafu528.gallerymultipicker.MultiPickerActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { super.onOptionsItemSelected(item); int id = item.getItemId(); if (id == android.R.id.home) { if (getSupportFragmentManager().getBackStackEntryCount() > 0) { getSupportFragmentManager().popBackStack(); } else {//from w w w. j a va 2 s . c o m setResult(RESULT_CANCELED); finish(); } } else if (id == R.id.info_shibafu528_gallerymultipicker_action_decide) { accept(getSelectedUris()); } else if (id == R.id.info_shibafu528_gallerymultipicker_action_gallery) { Intent intent = new Intent(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT ? Intent.ACTION_PICK : Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, REQUEST_GALLERY); } else if (id == R.id.info_shibafu528_gallerymultipicker_action_take_a_photo) { boolean existExternal = Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED); if (!existExternal) { Toast.makeText(this, R.string.info_shibafu528_gallerymultipicker_storage_error, Toast.LENGTH_SHORT) .show(); return true; } else { File extDestDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), mCameraDestDir != null ? mCameraDestDir : "Camera"); if (!extDestDir.exists()) { extDestDir.mkdirs(); } SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd_HHmmss"); String fileName = sdf.format(new Date(System.currentTimeMillis())); File destFile = new File(extDestDir.getPath(), fileName + ".jpg"); ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, fileName); values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); values.put(MediaStore.Images.Media.DATA, destFile.getPath()); mCameraTemp = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, mCameraTemp); startActivityForResult(intent, REQUEST_CAMERA); } } return true; }
From source file:de.wikilab.android.friendica01.activity.HomeActivity.java
void navigate(String arg1) { currentMMItem = arg1;/*from w w w.j ava2s .co m*/ if (arg1.equals(getResources().getString(R.string.mm_timeline))) { navigatePostList(getResources().getString(R.string.mm_timeline)); } if (arg1.equals(getResources().getString(R.string.mm_notifications))) { navigatePostList(getResources().getString(R.string.mm_notifications)); } if (arg1.equals(getResources().getString(R.string.mm_mywall))) { navigatePostList(getResources().getString(R.string.mm_mywall)); } if (arg1.equals(getResources().getString(R.string.mm_updatemystatus))) { navigateStatusUpdate(); } if (arg1.equals(getResources().getString(R.string.mm_friends))) { navigateFriendList(); } if (arg1.equals(getResources().getString(R.string.mm_myphotoalbums))) { navigatePhotoGallery(getResources().getString(R.string.mm_myphotoalbums)); } if (arg1.equals(getResources().getString(R.string.mm_takephoto))) { Intent in = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); takePhotoTarget = Max.getTempFile(); in.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(takePhotoTarget)); startActivityForResult(in, RQ_TAKE_PHOTO); } if (arg1.equals(getResources().getString(R.string.mm_selectphoto))) { Intent in = new Intent(Intent.ACTION_PICK); in.setType("image/*"); startActivityForResult(in, RQ_SELECT_PHOTO); } if (arg1.equals(getResources().getString(R.string.mm_directmessages))) { //Intent in = new Intent(HomeActivity.this, MessagesActivity.class); //startActivity(in); navigateMessages("msg:all"); } if (arg1.equals(getResources().getString(R.string.mm_preferences))) { navigatePreferences(); } if (arg1.equals(getResources().getString(R.string.mm_logout))) { SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(HomeActivity.this) .edit(); //prefs.putString("login_server", null); //keep server and user ... prefs.putString("login_user", null); prefs.putString("login_password", null); //...only remove password prefs.commit(); finish(); } }
From source file:kr.wdream.ui.WallpapersActivity.java
@Override public View createView(Context context) { Log.d(LOG_TAG, "createView"); actionBar.setBackButtonImage(kr.wdream.storyshop.R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(/*from ww w . j a v a 2 s. c om*/ LocaleController.getString("ChatBackground", kr.wdream.storyshop.R.string.ChatBackground)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override public void onItemClick(int id) { if (id == -1) { finishFragment(); } else if (id == done_button) { boolean done; TLRPC.WallPaper wallPaper = wallpappersByIds.get(selectedBackground); if (wallPaper != null && wallPaper.id != 1000001 && wallPaper instanceof TLRPC.TL_wallPaper) { int width = AndroidUtilities.displaySize.x; int height = AndroidUtilities.displaySize.y; if (width > height) { int temp = width; width = height; height = temp; } TLRPC.PhotoSize size = FileLoader.getClosestPhotoSizeWithSize(wallPaper.sizes, Math.min(width, height)); String fileName = size.location.volume_id + "_" + size.location.local_id + ".jpg"; File f = new File(FileLoader.getInstance().getDirectory(FileLoader.MEDIA_DIR_CACHE), fileName); File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper.jpg"); try { done = AndroidUtilities.copyFile(f, toFile); } catch (Exception e) { done = false; FileLog.e("tmessages", e); } } else { if (selectedBackground == -1) { File fromFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper-temp.jpg"); File toFile = new File(ApplicationLoader.getFilesDirFixed(), "wallpaper.jpg"); done = fromFile.renameTo(toFile); } else { done = true; } } if (done) { SharedPreferences preferences = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putInt("selectedBackground", selectedBackground); editor.putInt("selectedColor", selectedColor); editor.commit(); ApplicationLoader.reloadWallpaper(); } finishFragment(); } } }); ActionBarMenu menu = actionBar.createMenu(); doneButton = menu.addItemWithWidth(done_button, kr.wdream.storyshop.R.drawable.ic_done, AndroidUtilities.dp(56)); FrameLayout frameLayout = new FrameLayout(context); fragmentView = frameLayout; backgroundImage = new ImageView(context); backgroundImage.setScaleType(ImageView.ScaleType.CENTER_CROP); frameLayout.addView(backgroundImage, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); backgroundImage.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); progressView = new FrameLayout(context); progressView.setVisibility(View.INVISIBLE); frameLayout.addView(progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.LEFT, 0, 0, 0, 52)); progressViewBackground = new View(context); progressViewBackground.setBackgroundResource(kr.wdream.storyshop.R.drawable.system_loader); progressView.addView(progressViewBackground, LayoutHelper.createFrame(36, 36, Gravity.CENTER)); ProgressBar progressBar = new ProgressBar(context); try { progressBar.setIndeterminateDrawable( context.getResources().getDrawable(kr.wdream.storyshop.R.drawable.loading_animation)); } catch (Exception e) { //don't promt } progressBar.setIndeterminate(true); AndroidUtilities.setProgressBarAnimationDuration(progressBar, 1500); progressView.addView(progressBar, LayoutHelper.createFrame(32, 32, Gravity.CENTER)); RecyclerListView listView = new RecyclerListView(context); listView.setClipToPadding(false); listView.setTag(8); listView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), 0); LinearLayoutManager layoutManager = new LinearLayoutManager(context); layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL); listView.setLayoutManager(layoutManager); listView.setDisallowInterceptTouchEvents(true); listView.setOverScrollMode(RecyclerListView.OVER_SCROLL_NEVER); listView.setAdapter(listAdapter = new ListAdapter(context)); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 102, Gravity.LEFT | Gravity.BOTTOM)); listView.setOnItemClickListener(new RecyclerListView.OnItemClickListener() { @Override public void onItemClick(View view, int position) { if (position == 0) { if (getParentActivity() == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); CharSequence[] items = new CharSequence[] { LocaleController.getString("FromCamera", kr.wdream.storyshop.R.string.FromCamera), LocaleController.getString("FromGalley", kr.wdream.storyshop.R.string.FromGalley), LocaleController.getString("Cancel", kr.wdream.storyshop.R.string.Cancel) }; builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { try { if (i == 0) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File image = AndroidUtilities.generatePicturePath(); if (image != null) { if (Build.VERSION.SDK_INT >= 24) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, FileProvider.getUriForFile(getParentActivity(), BuildConfig.APPLICATION_ID + ".provider", image)); takePictureIntent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); } else { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(image)); } currentPicturePath = image.getAbsolutePath(); } startActivityForResult(takePictureIntent, 10); } else if (i == 1) { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, 11); } } catch (Exception e) { FileLog.e("tmessages", e); } } }); showDialog(builder.create()); } else { if (position - 1 < 0 || position - 1 >= wallPapers.size()) { return; } TLRPC.WallPaper wallPaper = wallPapers.get(position - 1); selectedBackground = wallPaper.id; listAdapter.notifyDataSetChanged(); processSelectedBackground(); } } }); processSelectedBackground(); return fragmentView; }
From source file:hku.fyp14017.blencode.ui.dialogs.NewSpriteDialog.java
private void setupPaintroidButton(View parentView) { View paintroidButton = parentView.findViewById(hku.fyp14017.blencode.R.id.dialog_new_object_paintroid); final Intent intent = new Intent("android.intent.action.MAIN"); intent.setComponent(new ComponentName(Constants.POCKET_PAINT_PACKAGE_NAME, Constants.POCKET_PAINT_INTENT_ACTIVITY_NAME)); paintroidButton.setOnClickListener(new View.OnClickListener() { @Override//from w ww .ja v a 2s .c o m public void onClick(View view) { if (LookController.getInstance().checkIfPocketPaintIsInstalled(intent, getActivity())) { Intent intent = new Intent("android.intent.action.MAIN"); intent.setComponent(new ComponentName(Constants.POCKET_PAINT_PACKAGE_NAME, Constants.POCKET_PAINT_INTENT_ACTIVITY_NAME)); Bundle bundleForPocketPaint = new Bundle(); bundleForPocketPaint.putString(Constants.EXTRA_PICTURE_PATH_POCKET_PAINT, ""); bundleForPocketPaint.putString(Constants.EXTRA_PICTURE_NAME_POCKET_PAINT, getString(hku.fyp14017.blencode.R.string.default_look_name)); intent.putExtras(bundleForPocketPaint); intent.putExtra(MediaStore.EXTRA_OUTPUT, lookUri); intent.addCategory("android.intent.category.LAUNCHER"); startActivityForResult(intent, REQUEST_CREATE_POCKET_PAINT_IMAGE); } } }); }
From source file:com.awrtechnologies.carbudgetsales.MainActivity.java
public void imageOpen(Fragment f, final int REQUEST_CAMERA, final int SELECT_FILE) { GeneralHelper.getInstance(MainActivity.this).setTempFragment(f); final CharSequence[] items = { "Take Photo", "Choose from Library", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Add Photo!"); builder.setItems(items, new DialogInterface.OnClickListener() { @Override/* ww w . j ava 2 s . co m*/ public void onClick(DialogInterface dialog, int item) { if (items[item].equals("Take Photo")) { java.io.File imageFile = new File( (Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM) + "/." + Constants.APPNAME + "/" + System.currentTimeMillis() + ".jpeg")); PreferencesManager.setPreferenceByKey(MainActivity.this, "IMAGEWWC", imageFile.getAbsolutePath()); // imageFilePath = imageFile; imageFileUri = Uri.fromFile(imageFile); Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri); startActivityForResult(i, REQUEST_CAMERA); } else if (items[item].equals("Choose from Library")) { if (Build.VERSION.SDK_INT < 19) { 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); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE); } } else if (items[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.PostFragment.java
/** * Displays dialog and either launches camera or gallery * //from w w w. j a v a2 s . c o m * @param view * the AttachPhoto button in postThreadFragment. */ public void attachImage(View view) { if (view.getId() == R.id.attach_image_button) { AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); dialog.setTitle(R.string.attach_image_title); dialog.setMessage(R.string.attach_image_dialog); dialog.setPositiveButton("Gallery", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { FavouritesFragment favFrag = (FavouritesFragment) getParentFragment(); boolean fromFav; if (favFrag != null) { fromFav = true; } else { fromFav = false; } Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); if (fromFav == true) { arg0.dismiss(); getParentFragment().startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_GALLERY); } else { arg0.dismiss(); startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_GALLERY); } } }); dialog.setNegativeButton("Camera", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { FavouritesFragment favFrag = (FavouritesFragment) getParentFragment(); boolean fromFav; if (favFrag != null) { fromFav = true; } else { fromFav = false; } Intent intent = new Intent(); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); try { imageFile = ImageHelper.createImageFile(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile)); if (fromFav == true) { arg0.dismiss(); getParentFragment().startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_CAMERA); } else { arg0.dismiss(); startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_CAMERA); } } catch (IOException e) { e.printStackTrace(); } } }); dialog.show(); } }
From source file:com.mobility.android.ui.vehicle.AddVehicleActivity.java
private void takePicture() { imageFile = new File(getExternalCacheDir(), System.currentTimeMillis() + ".jpg"); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile)); startActivityForResult(intent, CAMERA_REQUEST); }
From source file:com.hplasplas.cam_capture.activitys.CamCapture.java
public void makePhoto() { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mCurrentPictureFile = FileSystemManager.generateFileForPicture(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(mCurrentPictureFile)); if (intent.resolveActivity(getPackageManager()) != null) { startActivityForResult(intent, GET_PICTURE_REQUEST_CODE); }/*from w w w . jav a2s . c o m*/ }
From source file:geert.stef.sm.beheerautokm.Overview.java
public void addNewImage(View view) { if (view.getId() == R.id.btnAddNewImage) { Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(getPackageManager()) != null) { File photoFile = null; try { photoFile = createImageFile(selectedCar.getCar()); } catch (IOException ex) { // Error occurred while creating the File }//ww w .ja va2 s . c o m // Continue only if the File was successfully created if (photoFile != null) { takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); startActivityForResult(takePictureIntent, REQUEST_CODE_CAPTURE); } } } }
From source file:com.androidquery.simplefeed.activity.PostActivity.java
public void photoClicked(View view) { File file = makePhotoFile();/*from w ww. ja v a 2s. co m*/ if (file == null) return; Uri outputFileUri = Uri.fromFile(file); Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); startActivityForResult(intent, Constants.ACTIVITY_CAMERA); }