A questo link viene descritto il medesimo problema
Un sistema per una app che scatta una foto e mette il risultato in una imageview ed effettua il salvataggio (gestione dei permessi di scrittura non gestita..vedi post precedenti)
-----------------------------------------------
package com.example.lucainnocenti.photonotation; import android.app.Activity; import android.content.Intent; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.os.Environment; import android.provider.MediaStore; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.Button; import android.widget.ImageView; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; public class MainActivity extends AppCompatActivity { private static final int CAMERA_REQUEST = 1888; private ImageView foto; private Bitmap ff; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); foto = (ImageView) findViewById(R.id.imageView); Button scatto = (Button) findViewById(R.id.button); scatto.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(camera, CAMERA_REQUEST); } }); } protected void onActivityResult(int requestCode,int resultCode, Intent data) { if (requestCode== CAMERA_REQUEST && resultCode == Activity.RESULT_OK){ ff = (Bitmap) data.getExtras().get("data"); foto.setImageBitmap(ff); foto.setImageURI(data.getData()); Bitmap bm=((BitmapDrawable)foto.getDrawable()).getBitmap(); saveImageFile(bm); } } public String saveImageFile(Bitmap bitmap) { FileOutputStream out = null; String filename = getFilename(); try { out = new FileOutputStream(filename); bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); } catch (FileNotFoundException e) { e.printStackTrace(); Log.d("luca22","Errore"); } return filename; } private String getFilename() { File file = new File(Environment.getExternalStorageDirectory() .getPath(), "TestFolder"); if (!file.exists()) { file.mkdirs(); } String uriSting = (file.getAbsolutePath() + "/" + System.currentTimeMillis() + ".jpg"); Log.d("luca22",uriSting); return uriSting; } }