简体   繁体   中英

How to save photo after capture at activity after closing it?

I have two activities - first opens the second. On the second activity, I can take photos and add them in an ImageView. But after I leave this activity the photo is missing and I need to shoot again.

I call second activity doing this:

 startActivity(Intent(this@MapsActivity, this.allPoints[it.tag as Int].second))

Here this.allPoints[it.tag as Int].second is the activity from collection.

Take photo in the second doing this:

 override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    if(requestCode==123){
        var bmp = data?.extras?.get("data") as Bitmap
        imageView.setImageBitmap(bmp)
    }
}

When I press "Back" it goes to the first activity, but do not save photo on the second as ImageView. How can I fix it?

I took a quick look over your code and it populates the image correctly, but you need to save the image somewheres for you to reuse it after finishing the second activity. It is by far great code just isn't completed yet is all. Save the image you created and re-render it where you need it.

Very impressive

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM