Skip to content

Instantly share code, notes, and snippets.

@cwdoh
Last active June 8, 2018 08:21
Show Gist options
  • Select an option

  • Save cwdoh/2843e5320e817e4638dc2088d01d6b7f to your computer and use it in GitHub Desktop.

Select an option

Save cwdoh/2843e5320e817e4638dc2088d01d6b7f to your computer and use it in GitHub Desktop.
JobScheduler
class JobSchedulerSample {
private static final int JOB_ID_UPDATE = 0x1000;
static void setUpdateJob(Context context) {
// 대용량 데이터를 업데이트하기 위한 적정 조건 설정
JobInfo job =
new JobInfo.Builder(
// Job에 설정할 Id 값
JOB_ID_UPDATE,
// 조건 만족 시 UpdateDataByWiFiService가 실행
new ComponentName(this, SyncJobService.class)
)
// 충분한 저장 공간이 있고,
.setRequiresStorageNotLow(true)
// WiFi 등의 비과금 네트워크를 사용 중이며
.setRequiredNetworksCapabilities(JobInfo.NETWORK_TYPE_UNMETERED)
// 충전 중 일 때
.setRequiresCharging(true)
.build();
// JobScheduler 서비스
JobService mJobService = (JobScheduler) context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
// Job을 등록한다.
mJobService.scheduleJob(job);
}
}
@ChaMinGyu
Copy link
Copy Markdown

라인 22번에 JobService가 아니라 JobScheduler 으로 mJobService을 선언해야되지 않나요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment