Android: determining the current context to display an alert

百般思念 提交于 2020-01-05 08:24:07

问题


I am calling the ZXing scanner from Screen-A using Intents. 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?


回答1:


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




回答2:


Can't you display a ProgressDialog before your call to ZXing and then dismiss it in onActivityResult() ?



来源:https://stackoverflow.com/questions/774545/android-determining-the-current-context-to-display-an-alert

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!