打开相机前显示对话框
Show Dialog before opening the camera
我想在相机打开前显示一条消息。
现在用户点击一个按钮,消息显示 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()
}
您必须将 cameraBtn 上的内容应用到警报中
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()
我想在相机打开前显示一条消息。
现在用户点击一个按钮,消息显示 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()
}
您必须将 cameraBtn 上的内容应用到警报中
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()