Skip to content
This repository was archived by the owner on Jul 25, 2019. It is now read-only.
This repository was archived by the owner on Jul 25, 2019. It is now read-only.

When the version is different from 21(LOLIPOP), it runs only once and stops. #32

@carreiraDesenvolvedor

Description

@carreiraDesenvolvedor

Good night.
When I ran the program in KITKAT the program did not go into Loop, run the code only once, but shows no error, just stopped, follows the JobService class, thanks:

public class JobSchedulerService extends JobService {

public static final String TAG = "LOG";

@Override
public boolean onStartJob(JobParameters params) {
    Log.i(TAG, "onStartJob("+params.getExtras().getString("string")+")");
    new MyAsyncTask(this).execute(params);
    return true;
}

@Override
public boolean onStopJob(JobParameters params) {
    Log.i(TAG, "onStopJob()");
    return true;
}

// INNER CLASS
    private static class MyAsyncTask extends AsyncTask<JobParameters, Void, String>{
        private JobSchedulerService jss;

        public MyAsyncTask(JobSchedulerService j){
            jss = j;
        }

        @Override
        protected String doInBackground(JobParameters... params) {
            Log.i(TAG, "doInBackground()");

            SystemClock.sleep(5000);

            String answer = HttpConnection
                                .getSetDataWeb("http://www.villopim.com.br/android/ExampleJobScheduler/get-random.php",
                                        "method");

            jss.jobFinished(params[0], true);

            return answer;
        }
        @Override
        protected void onPostExecute(String s) {
            Log.i(TAG, "onPostExecute()");

            EventBus.getDefault().post( new MessageEB( s ));
        }
    }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions