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 Nov 19 at 10:32
Florian Walther
8711519
8711519
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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