-
Notifications
You must be signed in to change notification settings - Fork 76
JobService is not running #36
Description
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