Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent) {
- try {
- String file_path = "";
- super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
- if (resultCode == RESULT_OK) {
- if (requestCode == CAMERA_REQUEST) {
- Bitmap thumbnail = (Bitmap) imageReturnedIntent.getExtras().get("data");
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- thumbnail.compress(Bitmap.CompressFormat.JPEG, 90, bytes);
- File destination = new File(Environment.getExternalStorageDirectory(),
- System.currentTimeMillis() + ".jpg");
- file_path = destination.getPath();
- editor.putString("image_path", file_path);
- editor.commit();
- FileOutputStream fo;
- try {
- destination.createNewFile();
- fo = new FileOutputStream(destination);
- fo.write(bytes.toByteArray());
- fo.close();
- Picasso.with(Sell_Main.this).load(destination).into(imgone);
- } catch (FileNotFoundException e) {
- Toast.makeText(Sell_Main.this, e.getMessage(), Toast.LENGTH_SHORT).show();
- } catch (IOException e) {
- Toast.makeText(Sell_Main.this, e.getMessage(), Toast.LENGTH_SHORT).show();
- }
- }
- }
- } catch (Exception e) {
- Toast.makeText(Sell_Main.this, e.getMessage(), Toast.LENGTH_SHORT).show();
- }
- }
- public void Image_Picker_Dialog()
- {
- AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
- myAlertDialog.setMessage("Select Picture Mode");
- myAlertDialog.setPositiveButton("Gallery", new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface arg0, int arg1)
- {
- Intent pickPhoto = new Intent(Intent.ACTION_PICK,android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
- pickPhoto.putExtra(Intent.EXTRA_ALLOW_MULTIPLE,true);
- startActivityForResult(pickPhoto , 1);
- }
- });
- myAlertDialog.setNegativeButton("Camera", new DialogInterface.OnClickListener()
- {
- public void onClick(DialogInterface arg0, int arg1)
- {
- Intent takePicture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- takePicture.putExtra(Intent.EXTRA_ALLOW_MULTIPLE,true);
- startActivityForResult(takePicture, 0);
- }
- });
- myAlertDialog.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement