I'm trying to put up a progress bar while reading and processing a
file. I'm open to title bar vs dialog and determinate vs.
indeterminate. At this point I don't care, I just want to get
something working. The problem occurs as the working thread attempts
to turn the progress bar off. At that point the program crashes. In
the example below ".F" is never written to the log.
Any help is appreciated.
Thanks.
The following code subs the actual file reading and processing out and
replace it with sleep() for the time being.
private void read() {
//First test without a thread...this works without crashing,
but of
course the progress bar is never
//shown or updated because the main thread is locked up doing
work
(sleeping in this example).
Log.v("Thread/Progress test", "a");
//showDialog(INDETERMINATE_DLOG_ID);
setProgressBarIndeterminateVisibility(true);
Log.v("Thread/Progress test", "b");
try {
Log.v("Thread/Progress test", "c");
Thread.sleep(5000);
Log.v("Thread/Progress test", "d");
} catch (InterruptedException e) {
}
Log.v("Thread/Progress test", "e");
setProgressBarIndeterminateVisibility(false);
Log.v("Thread/Progress test", "f");
//Next try it with a separate working thread. Progress bar is
shown,
//but program crashes as working threads terminates the progress
bar.
Log.v("Thread/Progress test", "A");
setProgressBarIndeterminateVisibility(true);
Log.v("Thread/Progress test", "B");
new Thread(new Runnable() {
public void run() {
try {
Log.v("Thread/Progress test", ".C");
Thread.sleep(5000);
Log.v("Thread/Progress test", ".D");
} catch (InterruptedException e) {
}
Log.v("Thread/Progress test", ".E");
setProgressBarIndeterminateVisibility(false);
//dismissDialog(INDETERMINATE_DLOG_ID);
Log.v("Thread/Progress test", ".F");
} //Runnable.run()
}).start();
Log.v("Thread/Progress test", "G");
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---