JobIntentService - Should I stop the current work in onStopCurrentWork?
up vote
0
down vote
favorite
Lets take a very simple JobIntentService
as an example:
public class ExampleJobIntentService extends JobIntentService {
@Override
protected void onHandleWork(@NonNull Intent intent) {
for (int i = 0; i < 10; i++) {
SystemClock.sleep(1000);
}
}
static void enqueueWork(Context context, Intent work) {
enqueueWork(context, ExampleJobIntentService.class, 123, work);
}
}
When the job gets interrupted (for example because the device falls into doze), the current for-loop
keeps running until it is finished. In a real app this would be the actual background work. Will this cause any problems? Should I add a boolean
flag in onStopCurrentWork
that returns from onHandleWork
if the job is stopped?
android job-scheduling android-jobscheduler
add a comment |
up vote
0
down vote
favorite
Lets take a very simple JobIntentService
as an example:
public class ExampleJobIntentService extends JobIntentService {
@Override
protected void onHandleWork(@NonNull Intent intent) {
for (int i = 0; i < 10; i++) {
SystemClock.sleep(1000);
}
}
static void enqueueWork(Context context, Intent work) {
enqueueWork(context, ExampleJobIntentService.class, 123, work);
}
}
When the job gets interrupted (for example because the device falls into doze), the current for-loop
keeps running until it is finished. In a real app this would be the actual background work. Will this cause any problems? Should I add a boolean
flag in onStopCurrentWork
that returns from onHandleWork
if the job is stopped?
android job-scheduling android-jobscheduler
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Lets take a very simple JobIntentService
as an example:
public class ExampleJobIntentService extends JobIntentService {
@Override
protected void onHandleWork(@NonNull Intent intent) {
for (int i = 0; i < 10; i++) {
SystemClock.sleep(1000);
}
}
static void enqueueWork(Context context, Intent work) {
enqueueWork(context, ExampleJobIntentService.class, 123, work);
}
}
When the job gets interrupted (for example because the device falls into doze), the current for-loop
keeps running until it is finished. In a real app this would be the actual background work. Will this cause any problems? Should I add a boolean
flag in onStopCurrentWork
that returns from onHandleWork
if the job is stopped?
android job-scheduling android-jobscheduler
Lets take a very simple JobIntentService
as an example:
public class ExampleJobIntentService extends JobIntentService {
@Override
protected void onHandleWork(@NonNull Intent intent) {
for (int i = 0; i < 10; i++) {
SystemClock.sleep(1000);
}
}
static void enqueueWork(Context context, Intent work) {
enqueueWork(context, ExampleJobIntentService.class, 123, work);
}
}
When the job gets interrupted (for example because the device falls into doze), the current for-loop
keeps running until it is finished. In a real app this would be the actual background work. Will this cause any problems? Should I add a boolean
flag in onStopCurrentWork
that returns from onHandleWork
if the job is stopped?
android job-scheduling android-jobscheduler
android job-scheduling android-jobscheduler
asked yesterday
Florian Walther
8511517
8511517
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372684%2fjobintentservice-should-i-stop-the-current-work-in-onstopcurrentwork%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown