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

JobService is not running #36

Open
mallik482 opened this issue Jun 7, 2016 · 0 comments
Open

JobService is not running #36

mallik482 opened this issue Jun 7, 2016 · 0 comments

Comments

@mallik482
Copy link

mallik482 commented Jun 7, 2016

I have used this library Its working before. I don't no what I changed suddenly its not working

this my activity
private void setUpJobScheduler() {
jobScheduler = JobScheduler.getInstance(this);

    JobInfo job = new JobInfo.Builder(0, new ComponentName(this, NotificationJobService.class))
            .setRequiredNetworkType(JobInfo.NETWORK_TYPE_UNMETERED)
            .setRequiresCharging(false)
            .setPeriodic(10000)
            /*.setExtras(extras)*/
            .build();
    System.out.println("======= inside job scheduler");
    jobScheduler.schedule(job);
}

this is my job service

public class NotificationJobService extends JobService implements BroadcastListCallback,TextToSpeech.OnInitListener{
private final LinkedList jobParamsMap = new LinkedList();
Cache session;
TextToSpeech speech;
@OverRide
public boolean onStartJob(JobParameters params) {
jobParamsMap.add(params);
System.out.println("====== inside job "+session.getNotificationFlag());
if(session.getLogin() && session.getNotificationFlag()) {
System.out.println("=========== yes");
NotificationServiceTask task = new NotificationServiceTask(this, session.getUserID(), "received", "", "");
task.execute();
}else{
JobParameters parameters=jobParamsMap.poll();
if (parameters == null) {

        }else {
            jobFinished(parameters, false);
        }
    }
    return false;
}

@Override
public boolean onStopJob(JobParameters params) {
    jobParamsMap.remove(params);
    return false;
}

@Override
public void onBroadcastList(ArrayList<BroadcastRequests> list) {
    JobParameters parameters=jobParamsMap.poll();
    if (parameters == null) {

    }else {
        jobFinished(parameters, true);
    }

    System.out.println("======="+session.getRequestsCount() +"==="+ list.size());
    if(session.getType().equals("Retailer")){
        if(RetailersNavigationActivity.requestsCounter != null)
            RetailersNavigationActivity.requestsCounter.setText(list.size()+"");
    }else{
        if(NavigationActivity.requestsCounter != null)
            NavigationActivity.requestsCounter.setText(list.size()+"");
    }


}

@Override
public void onInit(int status) {
    if(status !=TextToSpeech.ERROR)
        speech.setLanguage(Locale.UK);
}

@Override
public void onCreate() {
    super.onCreate();
    session=new Cache(this);
    speech=new TextToSpeech(getApplicationContext(),this);
}

}

this service is not calling.

My manifest is


Tel me what is the reason

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant