How do I save this image in the gallery and access it again?

Asked

Viewed 60 times

1

I have this Xamarin Android App (not Forms) that just opens the camera and allows me to take a photo and go with it or resume. After I say I want to keep it, it appears in the app in an Imageview using a bitmap. Could not save it in the gallery using bitmap. I need you to be able to save in the gallery so I can make a new button later, which gets the last photo taken (the one taken with the app) and sends it to a server (I could use some help on that too). and that’s all I need to do. Here is the code Mainactivity.Cs:

using Android.App;

using Android.Widget;

using Android.OS;

using Android.Content;

using Android.Provider;

using Android.Runtime;

using Android.Graphics;

namespace CameraApp

{

    [Activity(Label = "@string/app_name", Theme = "@style/AppTheme", MainLauncher = true)]

    public class MainActivity : Activity

    {

        ImageView imageView;

        protected override void OnCreate(Bundle bundle)

        {

            base.OnCreate(bundle);

            SetContentView(Resource.Layout.activity_main);

            Button btnCamera = FindViewById<Button>(Resource.Id.btnCamera);

            imageView = FindViewById<ImageView>(Resource.Id.imageView);

            btnCamera.Click += BtnCamera_Click;

        }

        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)

        {

            base.OnActivityResult(requestCode, resultCode, data);

            Bitmap bitmap = (Bitmap)data.Extras.Get("data");

            imageView.SetImageBitmap(bitmap);

        }

        private void BtnCamera_Click(object sender, System.EventArgs e)

        {

            Intent intent = new Intent(MediaStore.ActionImageCapture);

            StartActivityForResult(intent, 0);

        }

    }

}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.