Skip to Content
안드로이드 멀티스레딩: 비동기 메커니즘으로 날렵하고 안정적인 앱 만들기
book

안드로이드 멀티스레딩: 비동기 메커니즘으로 날렵하고 안정적인 앱 만들기

by 한대희, 안데르스 예란손
April 2016
Beginner to intermediate
308 pages
7h 21m
Korean
Hanbit Media, Inc.
Content preview from 안드로이드 멀티스레딩: 비동기 메커니즘으로 날렵하고 안정적인 앱 만들기
238
2
-
비동기 기법
@
Override
public void onDestroy
()
{
super
.
onDestroy
();
mDownloadExecutor
.
shutdownNow
();
}
@
Override
public int onStartCommand
(
Intent intent
,
int flags
,
int startId
)
{
synchronized
(
this
)
{
mCommandCount
++;
}
if
(
intent
!
=
null
)
{
downloadFile
(
intent
.
getData
(),
startId
);
}
return START
_
REDELIVER
_
INTENT
;
3
}
private void downloadFile
(
final Uri uri
)
{
mDownloadExecutor
.
submit
(
new Runnable
()
{
@
Override
public void run
()
{
//
파일
다운로드
코드는
생략
synchronized
(
this
)
{
4
if
(
--mCommandCount
<
=
0
)
{
stopSelf
();
}
}
}
});
}
}
1
진행 중인 파일 다운로드의 수를 추적한다. 변수는 시작 요청을 받을 때 증가하고 백그라운드 태
스크가 완료될 때 감소한다.
2
인터페이스는 구현된
onBind
메서드를 필요로 하지만 이것은 바운드 서비스가
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.
Start your free trial

You might also like

코드로 인프라 관리하기: 효율적인 인프라 관리를 위한 자동화 방법

코드로 인프라 관리하기: 효율적인 인프라 관리를 위한 자동화 방법

강재준

Publisher Resources

ISBN: 9788968481703