List of usage examples for android.os Environment DIRECTORY_PICTURES
String DIRECTORY_PICTURES
To view the source code for android.os Environment DIRECTORY_PICTURES.
Click Source Link
From source file:ui.SelectImageActivity.java
public void takePhoto(View view) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(getPackageManager()) != null) { // Save the photo taken to a temporary file. File storageDir = getExternalFilesDir(Environment.DIRECTORY_PICTURES); try {//ww w .ja v a 2 s . co m File file = File.createTempFile("IMG_", ".jpg", storageDir); mUriPhotoTaken = Uri.fromFile(file); intent.putExtra(MediaStore.EXTRA_OUTPUT, mUriPhotoTaken); startActivityForResult(intent, REQUEST_TAKE_PHOTO); } catch (IOException e) { setInfo(e.getMessage()); } } }
From source file:com.example.carsharing.LongWayActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { photouri = Uri//from w ww. j a va 2 s .c o m .fromFile(new File(this.getExternalFilesDir(Environment.DIRECTORY_PICTURES), IMAGE_FILE_NAME2)); System.out.println("abc"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_long_way); activity_drawer = new Drawer(this, R.id.long_way_layout); mDrawerToggle = activity_drawer.newdrawer(); mDrawerLayout = activity_drawer.setDrawerLayout(); // standard_date = new SimpleDateFormat("yyyy-MM-dd", Locale.SIMPLIFIED_CHINESE); primary_date = new SimpleDateFormat("yyyyMMdd", Locale.SIMPLIFIED_CHINESE); queue = Volley.newRequestQueue(this); exchange = (ImageView) findViewById(R.id.longway_exchange); exchange.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub String temp = startplace.getText().toString(); startplace.setText(endplace.getText().toString()); endplace.setText(temp); } }); bdriver = true; datebutton = (Button) findViewById(R.id.longway_dates); increase = (Button) findViewById(R.id.longway_increase); decrease = (Button) findViewById(R.id.longway_decrease); s1 = (TextView) findViewById(R.id.longway_count); sure = (Button) findViewById(R.id.longway_sure); sure.setEnabled(false); startplace = (EditText) findViewById(R.id.longway_start_place); endplace = (EditText) findViewById(R.id.longway_end_place); noteinfo = (EditText) findViewById(R.id.longway_remarkText); commute = findViewById(R.id.drawer_commute); shortway = findViewById(R.id.drawer_shortway); longway = findViewById(R.id.drawer_longway); drawericon = (ImageView) findViewById(R.id.drawer_icon); drawername = (TextView) findViewById(R.id.drawer_name); drawernum = (TextView) findViewById(R.id.drawer_phone); carbrand = (EditText) findViewById(R.id.longway_CarBrand); model = (EditText) findViewById(R.id.longway_CarModel); color = (EditText) findViewById(R.id.longway_color); setting = findViewById(R.id.drawer_setting); licensenum = (EditText) findViewById(R.id.longway_Num); licensenum.addTextChangedListener(numTextWatcher); carbrand.addTextChangedListener(detTextWatcher); color.addTextChangedListener(coTextWatcher); model.addTextChangedListener(moTextWatcher); startplace.addTextChangedListener(spTextWatcher); endplace.addTextChangedListener(epTextWatcher); final TextView content = (TextView) findViewById(R.id.longway_content); longway_group = (RadioGroup) findViewById(R.id.longway_radiobutton); passangerRadioButton = (RadioButton) findViewById(R.id.longway_radioButton02); driverRadioButton = (RadioButton) findViewById(R.id.longway_radioButton01); personalcenter = findViewById(R.id.drawer_personalcenter); taxi = findViewById(R.id.drawer_taxi); // judge the value of "pre_page" Bundle bundle = this.getIntent().getExtras(); String PRE_PAGE = bundle.getString("pre_page"); if (PRE_PAGE.compareTo("ReOrder") == 0) { // startplace.setText(bundle.getString("stpmapname")); bstart = true; endplace.setText(bundle.getString("epmapname")); bend = true; datebutton.setText(bundle.getString("re_longway_startdate")); bdate = true; } // judge the value of "pre_page" // SharedPreferences sharedPref = this.getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE); UserPhoneNumber = sharedPref.getString(getString(R.string.PreferenceUserPhoneNumber), "0"); // database db = new DatabaseHelper(getApplicationContext(), UserPhoneNumber, null, 1); db1 = db.getWritableDatabase(); about = findViewById(R.id.drawer_respond); about.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent about = new Intent(LongWayActivity.this, AboutActivity.class); startActivity(about); } }); setting.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent setting = new Intent(LongWayActivity.this, SettingActivity.class); startActivity(setting); } }); // database end taxi.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); personalcenter.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent personalcenter = new Intent(LongWayActivity.this, PersonalCenterActivity.class); personalcenter.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(personalcenter); } }); // RadioGroup longway_group.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup arg0, int checkedId) { // TODO Auto-generated method stub18 // ID // """"textView if (checkedId == passangerRadioButton.getId()) { bpassenager = true; bdriver = false; licensenum.setEnabled(false); carbrand.setEnabled(false); color.setEnabled(false); model.setEnabled(false); licensenum.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); carbrand.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); color.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); model.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return source.length() < 1 ? dest.subSequence(dstart, dend) : ""; } } }); content.setText(getString(R.string.warningInfo_seatNeed)); licensenum.setHintTextColor(Color.parseColor("#cccccc")); carbrand.setHintTextColor(Color.parseColor("#cccccc")); color.setHintTextColor(Color.parseColor("#cccccc")); model.setHintTextColor(Color.parseColor("#cccccc")); licensenum.setInputType(InputType.TYPE_NULL); carbrand.setInputType(InputType.TYPE_NULL); color.setInputType(InputType.TYPE_NULL); model.setInputType(InputType.TYPE_NULL); } else { bpassenager = false; bdriver = true; licensenum.setEnabled(true); carbrand.setEnabled(true); color.setEnabled(true); model.setEnabled(true); licensenum.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); carbrand.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); color.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); model.setFilters(new InputFilter[] { new InputFilter() { @Override public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { return null; } } }); content.setText(getString(R.string.warningInfo_seatOffer)); licensenum.setHintTextColor(Color.parseColor("#9F35FF")); carbrand.setHintTextColor(Color.parseColor("#9F35FF")); color.setHintTextColor(Color.parseColor("#9F35FF")); model.setHintTextColor(Color.parseColor("#9F35FF")); // licensenum.setText(""); // carbrand.setText(""); // color.setText(""); // model.setText(""); licensenum.setInputType(InputType.TYPE_CLASS_TEXT); carbrand.setInputType(InputType.TYPE_CLASS_TEXT); color.setInputType(InputType.TYPE_CLASS_TEXT); model.setInputType(InputType.TYPE_CLASS_TEXT); // start! selectcarinfo(UserPhoneNumber); // end! } confirm(); } private void selectcarinfo(final String phonenum) { // TODO Auto-generated method stub String carinfo_selectrequest_baseurl = getString(R.string.uri_base) + getString(R.string.uri_CarInfo) + getString(R.string.uri_selectcarinfo_action); Log.d("carinfo_selectrequest_baseurl", carinfo_selectrequest_baseurl); StringRequest stringRequest = new StringRequest(Request.Method.POST, carinfo_selectrequest_baseurl, new Response.Listener<String>() { @Override public void onResponse(String response) { // TODO Auto-generated method stub Log.d("carinfo_select", response); String jas_id = null; JSONObject json1 = null; try { json1 = new JSONObject(response); JSONObject json = json1.getJSONObject("result"); jas_id = json.getString("id"); if (jas_id.compareTo("") != 0) { // carinfochoosing_type = 2; carbrand.setText(json.getString("carBrand")); model.setText(json.getString("carModel")); licensenum.setText(json.getString("carNum")); color.setText(json.getString("carColor")); } { carinfochoosing_type = 1; } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO Auto-generated method stub Log.e("carinfo_selectresult_result", error.getMessage(), error); } }) { protected Map<String, String> getParams() { Map<String, String> params = new HashMap<String, String>(); params.put("phonenum", phonenum); return params; } }; queue.add(stringRequest); } }); sure.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub if (longway_group.getCheckedRadioButtonId() == passangerRadioButton.getId()) userrole = "p"; else userrole = "d"; // start! Context phonenumber = LongWayActivity.this; SharedPreferences filename = phonenumber .getSharedPreferences(getString(R.string.PreferenceDefaultName), Context.MODE_PRIVATE); username = filename.getString("refreshfilename", "0"); longway_request(username, userrole, datebutton.getText().toString(), startplace.getText().toString(), endplace.getText().toString(), noteinfo.getText().toString()); // end! } private void longway_request(final String longway_phonenum, final String longway_userrole, final String longway_startdate, final String longway_startplace, final String longway_destination, final String longway_noteinfo) { // TODO Auto-generated method stub String longway_addrequest_baseurl = getString(R.string.uri_base) + getString(R.string.uri_LongwayPublish) + getString(R.string.uri_addpublish_action); // + "phonenum=" + longway_phonenum // + "&userrole=" + longway_userrole // + "&startdate=" + standard_longway_startdate // + "&startplace=" + longway_startplace // + "&destination=" + longway_destination // + "¬einfo=" + longway_noteinfo; // Log.d("longway_baseurl",longway_addrequest_baseurl); StringRequest stringRequest = new StringRequest(Request.Method.POST, longway_addrequest_baseurl, new Response.Listener<String>() { @Override public void onResponse(String response) { Log.d("longway_result", response); JSONObject json1 = null; try { json1 = new JSONObject(response); requestok = json1.getBoolean("result"); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (requestok == true) { if (carinfochoosing_type == 1) { // add // start! carinfo(longway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 1); // end! } else { // update // start! carinfo(longway_phonenum, licensenum.getText().toString(), carbrand.getText().toString(), model.getText().toString(), color.getText().toString(), String.valueOf(sum), 2); // end! } Intent sure = new Intent(LongWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "true"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } else { // Toast errorinfo = // Toast.makeText(getApplicationContext(), // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(LongWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Log.e("longway_result", error.getMessage(), error); // Toast errorinfo = Toast.makeText(null, // "", Toast.LENGTH_LONG); // errorinfo.show(); Intent sure = new Intent(LongWayActivity.this, OrderResponseActivity.class); sure.putExtra(getString(R.string.request_response), "false"); sure.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(sure); } }) { protected Map<String, String> getParams() { // POSTgetParams // start try { test_date = primary_date.parse(longway_startdate); standard_longway_startdate = standard_date.format(test_date); } catch (ParseException e) { // TODO Auto-generated catch block e.printStackTrace(); } // end! Map<String, String> params = new HashMap<String, String>(); params.put(getString(R.string.uri_phonenum), longway_phonenum); params.put(getString(R.string.uri_userrole), longway_userrole); params.put(getString(R.string.uri_startplace), longway_startplace); params.put(getString(R.string.uri_destination), longway_destination); params.put(getString(R.string.uri_startdate), standard_longway_startdate); params.put(getString(R.string.uri_noteinfo), longway_noteinfo); return params; } }; queue.add(stringRequest); } }); // start! shortway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent shortway = new Intent(LongWayActivity.this, ShortWayActivity.class); startActivity(shortway); } }); longway.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); } }); commute.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub mDrawerLayout.closeDrawer(findViewById(R.id.left_drawer)); Intent commute = new Intent(LongWayActivity.this, CommuteActivity.class); startActivity(commute); } }); // end! increase.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum++; s1.setText("" + sum); confirm(); } }); decrease.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub sum--; if (sum < 0) { sum = 0; } s1.setText("" + sum); confirm(); } }); datebutton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { // TODO Auto-generated method stub showDialog(DATE_DIALOG); } }); }
From source file:org.chaos.fx.cnbeta.details.ImageFragment.java
private String getImageCachePath() { String fileName = CryptUtil.encryptToMD5(mUrl) + FILE_SUFFIX; return getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES) + File.separator + fileName; }
From source file:com.sebible.cordova.videosnapshot.VideoSnapshot.java
/** * Take snapshots of a video file//w ww .j a va2 s . co m * * @param source path of the file * @param count of snapshots that are gonna be taken */ private void snapshot(final JSONObject options) { final CallbackContext context = this.callbackContext; this.cordova.getThreadPool().execute(new Runnable() { public void run() { MediaMetadataRetriever retriever = new MediaMetadataRetriever(); try { int count = options.optInt("count", 1); int countPerMinute = options.optInt("countPerMinute", 0); int quality = options.optInt("quality", 90); String source = options.optString("source", ""); Boolean timestamp = options.optBoolean("timeStamp", true); String prefix = options.optString("prefix", ""); int textSize = options.optInt("textSize", 48); if (source.isEmpty()) { throw new Exception("No source provided"); } JSONObject obj = new JSONObject(); obj.put("result", false); JSONArray results = new JSONArray(); Log.i("snapshot", "Got source: " + source); Uri p = Uri.parse(source); String filename = p.getLastPathSegment(); FileInputStream in = new FileInputStream(new File(p.getPath())); retriever.setDataSource(in.getFD()); String tmp = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); long duration = Long.parseLong(tmp); if (countPerMinute > 0) { count = (int) (countPerMinute * duration / (60 * 1000)); } if (count < 1) { count = 1; } long delta = duration / (count + 1); // Start at duration * 1 and ends at duration * count if (delta < 1000) { // min 1s delta = 1000; } Log.i("snapshot", "duration:" + duration + " delta:" + delta); File storage = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); for (int i = 1; delta * i < duration && i <= count; i++) { String filename2 = filename.replace('.', '_') + "-snapshot" + i + ".jpg"; File dest = new File(storage, filename2); if (!storage.exists() && !storage.mkdirs()) { throw new Exception("Unable to access storage:" + storage.getPath()); } FileOutputStream out = new FileOutputStream(dest); Bitmap bm = retriever.getFrameAtTime(i * delta * 1000); if (timestamp) { drawTimestamp(bm, prefix, delta * i, textSize); } bm.compress(Bitmap.CompressFormat.JPEG, quality, out); out.flush(); out.close(); results.put(dest.getAbsolutePath()); } obj.put("result", true); obj.put("snapshots", results); context.success(obj); } catch (Exception ex) { ex.printStackTrace(); Log.e("snapshot", "Exception:", ex); fail("Exception: " + ex.toString()); } finally { try { retriever.release(); } catch (RuntimeException ex) { } } } }); }
From source file:com.waz.zclient.pages.main.conversation.AssetIntentsManager.java
/** * Create a File for saving an image or video * * @param type// ww w.j ava 2 s.c o m */ private static File getOutputMediaFile(IntentType type) { File mediaStorageDir = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "WIRE_MEDIA"); if (!mediaStorageDir.exists() && !mediaStorageDir.mkdirs()) { return null; } java.util.Date date = new java.util.Date(); String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.getDefault()).format(date.getTime()); switch (type) { case VIDEO_CURSOR_BUTTON: case VIDEO: return new File(mediaStorageDir.getPath() + File.separator + "VID_" + timeStamp + ".mp4"); case CAMERA: return new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg"); } return null; }
From source file:com.pillowapps.liqear.activities.ImagePagerActivity.java
@Override public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) { int itemId = item.getItemId(); switch (itemId) { case android.R.id.home: finish();//from w w w . j a va 2s .c om Intent intent = new Intent(ImagePagerActivity.this, MainActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); break; case R.id.download_image_button: { if (imageUrls.size() <= pager.getCurrentItem()) { break; } String imageUrl = imageUrls.get(pager.getCurrentItem()); String root = Environment.getExternalStorageDirectory() + "/" + Environment.DIRECTORY_PICTURES; File myDir = new File(root); if (!myDir.exists()) { boolean directoryCreated = myDir.mkdirs(); if (!directoryCreated) { break; } } String fileName = artist + "_" + Utils.formatMillisToFileName(System.currentTimeMillis()) + ".jpg"; File fileForImage = new File(myDir, fileName); InputStream sourceStream = null; OutputStream targetStream = null; File cachedImage = ImageLoader.getInstance().getDiscCache().get(imageUrl); try { if (cachedImage.exists()) { // if image was cached by UIL sourceStream = new FileInputStream(cachedImage); } else { // otherwise - download image ImageDownloader downloader = new URLConnectionImageDownloader(); sourceStream = downloader.getStream(new URI(imageUrl)); } targetStream = new FileOutputStream(fileForImage); FileUtils.copyStream(sourceStream, targetStream); Toast.makeText(ImagePagerActivity.this, getString(R.string.saved) + " " + fileForImage.getAbsolutePath(), Toast.LENGTH_SHORT) .show(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (URISyntaxException e) { e.printStackTrace(); } finally { if (targetStream != null) { try { targetStream.close(); } catch (IOException ignored) { } } if (sourceStream != null) { try { sourceStream.close(); } catch (IOException ignored) { } } } } break; default: break; } return false; }
From source file:io.realm.scanner.MainActivity.java
private void copyTestAssetIfNeeded() { String imagePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + File.separator + TEST_IMAGE; if (new File(imagePath).exists()) { return;//from ww w . j av a2s. c om } AssetManager assetManager = getAssets(); try { InputStream in = assetManager.open(TEST_IMAGE); OutputStream out = new FileOutputStream(imagePath); byte[] buffer = new byte[PRIME_NUMBER_1000th]; int read; while ((read = in.read(buffer)) != -1) { out.write(buffer, 0, read); } in.close(); out.flush(); out.close(); MediaScannerConnection.scanFile(this, new String[] { imagePath }, new String[] { "image/jpeg" }, null); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.owncloud.android.ui.helpers.FilesUploadHelper.java
private File createImageFile() { try {/*from ww w .ja v a2 s. c o m*/ File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES); image = File.createTempFile(getCapturedImageName(), ".jpg", storageDir); capturedPhotoPath = image.getAbsolutePath(); } catch (IOException exception) { Log_OC.d(TAG, exception.toString()); } return image; }
From source file:de.skubware.opentraining.activity.create_exercise.ImageFragment.java
/** * Generates a unique filename and creates an empty file to use. * /*from ww w .j a v a2 s . c o m*/ * * @param internal For use within this app an internal folder is the right choice. * If the Uri should be passed to another app(e.g. camera app) an external folder has to be created. * Otherwise external apps cannot acces the folder. * * @return * @throws IOException */ private Uri createImageFile(boolean internal) throws IOException { // Create an image file name String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String imageFileName = "JPEG_" + timeStamp + "_"; File customImageFolder; if (internal) { customImageFolder = new File( getActivity().getFilesDir().toString() + "/" + IDataProvider.CUSTOM_IMAGES_FOLDER); } else { customImageFolder = new File( Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "OpenTraining"); } if (!customImageFolder.exists()) { customImageFolder.mkdirs(); Log.d(TAG, "Folder for custom exercise images does not exist, will create it now."); } File image = File.createTempFile(imageFileName, /* prefix */ ".jpg", /* suffix */ customImageFolder /* directory */ ); return Uri.fromFile(image); }
From source file:it.smartcampuslab.riciclo.FeedbackFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == 100) { if (resultCode != 0) { // Uri imgUri = data.getData(); File mediaStorageDir = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); File fi = new File(mediaStorageDir + File.separator + "tmpImg.jpg"); if (fi.exists()) { try { Uri imgUri = Uri.parse(android.provider.MediaStore.Images.Media .insertImage(getActivity().getContentResolver(), fi.getAbsolutePath(), null, null)); imageUri = imgUri.toString(); final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; BitmapFactory.decodeFile(fi.getAbsolutePath(), options); options.inSampleSize = calculateInSampleSize(options, dpToPx(IMG_HEIGHT), dpToPx(IMG_HEIGHT)); options.inJustDecodeBounds = false; Bitmap myBitmap = BitmapFactory.decodeFile(fi.getAbsolutePath(), options); ImageView myImage = (ImageView) getView().findViewById(R.id.feedback_img_result); myImage.setVisibility(View.VISIBLE); myImage.setImageBitmap(myBitmap); } catch (Exception e) { e.printStackTrace(); Log.e("CaptureHelper", "Error reading image"); }/*from w w w. j a va 2s . co m*/ } } } super.onActivityResult(requestCode, resultCode, data); }