OnRun ofroid-priority-jobqueue not called

I am trying to integrate android-priority-jobqueue into android, but onRun is not called, I don't know what I'm doing wrong.

Here is my Job class

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() {

    }
}

This is how I challenge

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

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

What am I doing wrong, how to make it work.

+4
source share

Source: https://habr.com/ru/post/1630002/


All Articles