0

I have built an Android application that allows the user to take pictures, I don't need to save the picture to the photo album but I want to give to picture a custom name and I don't know how to do. This is how I open the camera:

addButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

        Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
    }
});

and this is how I save the photo:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if( requestCode == CAMERA_PIC_REQUEST) {

        Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
        DataManager.bars.get((Integer) getIntent().getSerializableExtra("bar")).images.add(thumbnail); // here I save the picture to my custom object
        this.adapter.notifyDataSetChanged(); // I update the recycler view in order to see the pic

    } else {
        Toast.makeText(this, "Picture Not taken", Toast.LENGTH_LONG).show();
    }
}
Vladimir Vagaytsev
  • 2,871
  • 9
  • 33
  • 36
Francesco
  • 51
  • 2
  • 8
  • `// here I save the picture to my custom object` Save a name too to your objec. Are names displayed in your RecycleView for the other ones? WHat else do you need a name for? – blackapps Oct 13 '19 at 10:44
  • You are not checking the value of `resultCode`. Do. The user can cancel the take picture operation. At this moment you will add a non existing picture to the database if the user cancels. Please try and see. – blackapps Oct 13 '19 at 10:45
  • @blackapps Yes I save also a name and I display it but after I save the image I need to send it to a remote server and I need to use the name I save: the image must have the same name I assign to the object – Francesco Oct 13 '19 at 10:57
  • Then what is the problem exactly? – blackapps Oct 13 '19 at 10:59
  • @blackapps I don't know how to give to the image my custom name, when I send the image to the server it must have the name I assign to the object – Francesco Oct 13 '19 at 11:00
  • @blackapps what value should have result code? – Francesco Oct 13 '19 at 11:04
  • Toast() or Log.d() the value and you will soon find out. Or look at the hundreds of examples of onActivityResult() you can find on this site. – blackapps Oct 13 '19 at 11:06
  • Try to use picasso api, please refere to this : https://stackoverflow.com/questions/35694055/profile-image-uploader-and-load-it-with-picasso – Omar Amaoun Oct 14 '19 at 10:12

0 Answers0