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(); | |
} | |
} |
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
why? how?