0
I have an android app that uses the camera to take pictures and show on a ImageView
, Only the photo is not saved in the gallery. I would like to know how to save the image in the gallery and take the path of this image that was saved, because I need it to use in another function. Below follows the code of what I have done so far:
public class Capturar extends AppCompatActivity{
private static final int CAMERA = 1;
private ImageView imageView;
private String caminhoDaImagem;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_capturar);
imageView = (ImageView) findViewById(R.id.ivImg);
}
public void usarCamera(View view) {
Intent it = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(it, CAMERA);
}
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == CAMERA){
if(resultCode == RESULT_OK){
Bitmap bitmap = (Bitmap)intent.getExtras().get("data");
imageView.setImageBitmap(bitmap);
}
}
}
NOTE: What I want to get is the REAL image taken by the camera. As it is in the code I posted, what is being shown in ImageView
is only a temporary thumbnail generated and not the actual photo.
Related: Doubts regarding the use of the camera, via Intent
– ramaral
@ramaral thank you for answering, but this solution does not solve my problem. What I want is for the photo taken by the camera to go straight to the gallery and after saved in the gallery I have a way to get her address. As it was done in this solution that you mentioned, it is necessary to create a folder on the smartphone’s SD card where the application will run, which cannot happen in the application that I am developing. Nevertheless, thank you for your attention and for responding!
– CloudAC
The photos are not recorded in the Gallery. The Gallery is a database where it is stored, among other things, the path for photos on the device. Your app should save it to a particular location and then inform Gallery. See this reply to find out how.
– ramaral
I understood @ramaral, in fact I ended up being mistaken in this subject because I’m still layman in it. I was able to understand that the gallery is just a database that stores the paths where the images are. What I wanted was for my application to save the photos taken in one of the default folders on the device, just like the camera’s native app does. The user "Monitorlpi" was able to help me on this issue, but I thank you very much for clarifying this subject.
– CloudAC