Last active
March 6, 2019 10:12
-
-
Save cwdoh/f8b720dc428cfbb95b27cb83f0bc968a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import android.content.Intent; | |
import android.support.v4.app.JobIntentService; | |
import android.util.Log; | |
import android.widget.Toast; | |
import | |
/** | |
* Example implementation of a JobIntentService. | |
*/ | |
public class UpdateJobIntentService extends JobIntentService { | |
static final int JOB_ID = 1000; | |
static final String WORK_DOWNLOAD_ARTWORK = ".DOWNLOAD_ARTWORK"; | |
ArtworkDownloader mDownloader; | |
static void enqueueWork(Context context, Intent work) { | |
enqueueWork(context, Update.class, JOB_ID, work); | |
} | |
@Override | |
public void onCreate() { | |
super.onCreate(); | |
mDownloader = ArtworkDownloader.getSequencialDownloader(); | |
} | |
@Override | |
protected void onHandleWork(Intent intent) { | |
// enqueueWork()에 의해 적재된 인텐트는 여기로 전달됩니다. | |
if (WORK_DOWNLOAD_ARTWORK.equals(intent.getAction())) { | |
mDownloader.download(intent.getStringExtra("URL")) | |
} | |
} | |
@Override | |
public boolean onStopCurrentWork() { | |
// 현재 처리 중인 동작들을 중지해야 할 경우 | |
return !mDownloader.isFinished(); | |
} | |
} |
@smsrobot I am having the same issue in my own codebase. Let me know if you find a solution..
Per Android documentation, a subclassed JobIntentService should be started by calling the static enqueueWork() method.
Line 16, what is Update.class
? Should it be UpdateJobIntentService.class
instead?
onHandleWork does work. If your code is having this ,
@OverRide
public IBinder onBind(Intent intent) {
return null;
}
remove it and it will work.
onHandleWork does work. If your code is having this ,
@OverRide
public IBinder onBind(Intent intent) {
return null;
}
remove it and it will work.
why? how?
How to call jobintentservice class from activity?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
onHandleWork does not get Called on Android O (SDK 26), while on sdk < 26 it works
why ?