Android:在显示另一个对话框之前关闭一个对话框
我的应用程序在某些情况下会显示警报对话框。此外,用户可以使用 VIEW/SEND 意图启动我的应用程序。我正在考虑的场景是,对话框可见,用户按“Home”&选择我的应用程序来查看/共享文件。
我想在开始查看/共享操作之前关闭该对话框。虽然我可以维护哪个对话框可见并在操作开始之前隐藏它,但我想知道是否有常规/推荐的方法或 API,例如 activity.dismissAnyVisibleDialog()
可以派上用场。
非常感谢,
阿克谢
My application displays alert dialogs in some cases. Also, it is possible for a user to launch my application using the VIEW/SEND intent. The scenario I am considering is, the dialog is visible, the user presses 'Home' & selects my application to View/Share a file.
I would want to dismiss the dialog before beginning with the view/share operation. Although I can maintain which dialog is visible and hide it before the operation begins, I was wondering if there is a conventional/recommended way or API, something like activity.dismissAnyVisibleDialog()
that can come in handy.
Thanks a lot,
Akshay
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终自己维护了哪个对话框是可见的&在显示下一个之前将其忽略。
-阿克谢
I finally myself maintained which dialog is visible & dismissed it before displaying the next one.
-Akshay
只需关闭 onPause() 方法中的对话框(在您的活动中覆盖)。
这样,当活动不再可见时,即如果您切换到主屏幕,它将被关闭。
Just close the dialog in the onPause() method (override in your activity).
This way it will be dismissed when the activity is no longer visible i.e if you switch to the home screen.