最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

android - How to take a photo and send to another activity without user's click to accept it - Stack Overflow

programmeradmin5浏览0评论

I have a function to take pictures that goes like this:

    private fun takePicture() {
        Intent(MediaStore.ACTION_IMAGE_CAPTURE).also { takePictureIntent ->
            takePictureIntent.resolveActivity(packageManager)?.also {
                startActivityForResult(takePictureIntent, REQUEST_IMAGE_CAPTURE)
            }
        }
    }


    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
            val imageBitmap = data?.extras?.get("data") as Bitmap
        val mediaStorageDir = File(Environment.getExternalStoragePublicDirectory("Pics"), "CameraApp")
        val file: File("path/image.jpg")
        val outputStream = FileOutputStream(file)
        imageBitmappress(Bitmap.CompressFormat.JPEG, 100, outputStream)
        outputStream.close()
    }

The problem is this way I have two moments, the "taking picture" and the "accepting taken picture", as you can see below:

How do I avoid this "second moment" and send the user directly to another activity where he'll be able to accept the photo and do other stuff with it? If you have any other suggestion on how to do this or think I should change the way the picture is being taken I'd like to hear too.

发布评论

评论列表(0)

  1. 暂无评论