Trong trường hợp Service
và IntentService
những khác biệt chính là Service
chạy trên các chủ đề chính trong khi IntentService
không phải là, và kết thúc sau bản thân khi tác phẩm được thực hiện trong khi chúng ta phải gọi một trong hai stopService()
hoặc stopSelf()
để ngăn chặn một Service
.JobIntentService liên quan đến JobService như thế nào?
Cả hai chỉ có thể được chuyển đến startService()
.
Điều gì về JobService
và JobIntentService
?
Hãy lấy đoạn mã sau:
JobInfo job = new JobInfo.Builder(id, new ComponentName(context, ExampleJobService.class))
.build();
JobScheduler scheduler = (JobScheduler) context
.getSystemService(Context.JOB_SCHEDULER_SERVICE);
scheduler.schedule(job);
thể ExampleJobService.class
tham khảo cả một JobService
và một JobIntentService
?
Hành vi sẽ giống như với Service
và IntentService
(ngoài JobScheduler
không thể bắt đầu công việc ngay lập tức)?
JobIntentService có chạy trên một chuỗi khác không? –
** Alexander Farber **, theo [doc] (https://developer.android.com/reference/android/support/v4/app/JobIntentService.html#onHandleWork%28android.content.Intent%29) 'onHandleWork 'chạy trên chuỗi nền – user2650128