没有调用android-priority-jobqueue的onRun

时间:2016-02-23 06:02:30

标签: android android-priority-jobqueue

我正在尝试将android-priority-jobqueue集成到android中但是onRun没有被调用我不知道我做错了什么。

这是我的Job类

public class UpdateAttachmentJob extends Job {

    long id;
    String token;
    private static final String GROUP = "attachment";
    public static final int PRIORITY = 1;

    public UpdateAttachmentJob(long id,String token) {
        super(new Params(PRIORITY).requireNetwork().persist());
    this.id=id;
    this.token=token;
    }

    @Override
    public void onAdded() {

    }

    @Override
    public void onRun() throws Throwable {

        AttachmentTable tableItem = QueryClass.getData(id);

        new UpdateAttachmentsService().updateAttachment(id, tableItem.Name, tableItem.Description, tableItem.filePath,token ,new ApiCallBack() {

            @Override
            public void onSuccess(Object object) {

                BaseClass baseClass = (BaseClass) object;
                if (baseClass.getStatus() == Constants.status) {
                    QueryClass.deleteSyncTask(id);
                }

            }

            @Override
            public void onError(Object object, String message) {

            }
        });

    }

    @Override
    protected void onCancel() {

    }
}

以下是我如何称呼这份工作

if (mjobManager==null)
            mjobManager=new JobManager(context);

        mjobManager.addJobInBackground(new UpdateAttachmentJob(id,token));

我做错了什么,如何让它发挥作用

0 个答案:

没有答案