1

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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • Not familiar with ZXing scanner. Does it display something or is it just does a task in the background that signals when it's done? – JRL Apr 21 '09 at 21:22
  • Sorry for not explaining better. ZXing is a library that allows the camera to scan barcodes. So in my example I would have Screen-A open and make an intents call to ZXing (using startActivityForResult) which then activates the camera, captures and decodes the barcode. Upon returning the from ZXing I cannot reference the Screen-A context to display a "waiting" message. I'm not sure how to determine what context is available or, if none, how to bring a context to the foreground again. Help? –  Apr 22 '09 at 14:44

2 Answers2

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

Nikhil
  • 16,194
  • 20
  • 64
  • 81
Will
  • 19,789
  • 10
  • 43
  • 45
0

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

JRL
  • 76,767
  • 18
  • 98
  • 146
  • A good thought. When I try this I can see the progress dialog show up just before the scan window but after the scan it goes back to a black screen. Apparently ZXing is either holding onto another context or has temporarily elevated another context. Either way I'm not sure how to determine the current context to display the "working" dialog. Other ideas? –  Apr 26 '09 at 16:43