갱신, 또는 연쇄가 완료될 때까지 계속 보이도록 한다. 다음 예제에는 두 개의 연쇄적 태스크를
가진 핸들러 스레드가 있다. 그중 첫 번째 태스크만 액티비티에 노출되어 있다. 두 번째 태스크
는 독립 실행을 하지 못하고 첫 번째 태스크의 성공적인 실행 후에만 시작된다. 백그라운드 스레
드는 사용자가 볼 수 있는 대화상자를 제어하는 핸들러를 통해
UI
스레드와 통신한다.
public class ChainedNetworkActivity extends Activity
{
private static final int DIALOG
_
LOADING
=
0
;
private static final int SHOW
_
LOADING
=
1
;
private static final int DISMISS
_
LOADING
=
2
;
Handler dialogHandler
=
new Handler
()
{
1
@
Override
public void handleMessage
(
Message msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case SHOW
_
LOADING
:
showDialog
(
DIALOG
_
LOADING
);
break
;
case DISMISS
_
LOADING
:
dismissDialog
(
DIALOG
_
LOADING ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month, and much more.