Android:确定当前上下文以显示警报
我正在使用 Intent
从屏幕 A 调用 ZXing 扫描仪。 扫描完成后,控制权当然会返回到 Screen-A 后面的代码,并且在调用 Screen-B 之前我会做一些其他工作。
问题是:在此工作期间屏幕是黑色的,我无法确定用于显示“正在工作...”Toast/msgbox 的正确上下文。 有什么帮助或建议吗?
I am calling the ZXing scanner from Screen-A using Intent
s. Once the scan is done, control returns, of course, to the code behind Screen-A and I do some other work before calling Screen-B.
Problem is: the screen is black during this work period and I cannot determine the proper context to use to display a "working..." Toast/msgbox. Any help or suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在它自己的
线程
中执行您的“工作周期”,当该线程在后台工作时,Android 会将控制权传递给可显示进度条的 Screen-A。 “工作周期”线程将消息传递到屏幕A,更新测量进度的变量的值。 这里是开始使用 Android 线程的好地方:http://developer. android.com/guide/appendix/faq/commontasks.html#threading
Execute your "work period" in it's own
thread
, while that thread works in the background Android will pass control to Screen-A which will can display a ProgressBar. The "work period" thread will pass Messages to Screen-A updating the value of a variable that measures progress. Here's a good place to start with Android threads:http://developer.android.com/guide/appendix/faq/commontasks.html#threading
您不能在调用 ZXing 之前显示一个
ProgressDialog
,然后在onActivityResult()
中关闭它吗?Can't you display a
ProgressDialog
before your call to ZXing and then dismiss it inonActivityResult()
?