gpt4 book ai didi

android - 打开相机前显示对话框

转载 作者:行者123 更新时间:2023-12-05 00:15:17 25 4
gpt4 key购买 nike

我想在相机打开之前显示一条消息。

现在,用户单击按钮,消息将显示 1 秒钟,然后相机立即打开。一旦我关闭相机,对话框仍然可见。

我希望摄像头仅在您单击警报消息上的“确定”后才打开,并且一旦您关闭摄像头,该消息就不再显示。

//Button Picture
cameraBtn.setOnClickListener {
showDialog()
pb.visibility = View.VISIBLE
checkPermission(Manifest.permission.CAMERA,
CAMERA_PERMISSION_CODE)
startActivityForResult(receiptsViewModel.cameraIntent(requireActivity()),REQUEST_CODE_KAMERA)
}

fun showDialog() {
val dialogBuilder = AlertDialog.Builder(context)
dialogBuilder.setMessage("The message here")
dialogBuilder.setPositiveButton("Done",
DialogInterface.OnClickListener { dialog, whichButton -> })
val b = dialogBuilder.create()
b.show()
}

最佳答案

您必须将相机Btn上的内容应用到警报中

val dialogBuilder = AlertDialog.Builder(context)
dialogBuilder.setMessage("The message here")

dialogBuilder.setPositiveButton("Done"){dialogInterface, which ->
pb.visibility = View.VISIBLE
checkPermission(Manifest.permission.CAMERA,CAMERA_PERMISSION_CODE)
startActivityForResult(receiptsViewModel.cameraIntent(requireActivity()),REQUEST_CODE_KAMERA)
}

val b = dialogBuilder.create()
b.show()

关于android - 打开相机前显示对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67891382/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com