小编San*_*der的帖子

How to prevent Context leak in AsyncTask used by JobService

I need to do some background work which requires a Context in a JobService (I'm using the Firebase JobDispatcher one because we support api 16+) I've read a lot of articles about the JobService and AsyncTasks but I'm unable to find any good articles on how to combine them if you need a Context.

My JobService

import com.firebase.jobdispatcher.JobParameters;
import com.firebase.jobdispatcher.JobService;

public class AsyncJobService extends JobService {

    @Override
    public boolean onStartJob(JobParameters job) {
        new AsyncWork(this, job).execute();
        return true;
    }

    @Override
    public …
Run Code Online (Sandbox Code Playgroud)

android android-asynctask firebase-job-dispatcher

5
推荐指数
1
解决办法
1866
查看次数