I am creating a Firebase Job Dispatcher for sending Error crash report to the server. My Service is not starting with dispatcher's mustSchedule method. It might be due to I am starting my job, not on any activity. Here is my code...
Code for start Service:
public void scheduleJobForUploadCrashReport(Context context, Bundle serviceBundle) {
Logs.i(TAG, "scheduleJobForUploadCrashReport");
FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));
try {
Job job = createJobForuploadCrashReport(dispatcher, serviceBundle);
dispatcher.mustSchedule(job);
Logs.i(TAG, "dispatcher is scheduled---->");
} catch (FirebaseJobDispatcher.ScheduleFailedException e) {
Logs.e(TAG, "FirebaseJobDispatcher.ScheduleFailedException : " + e.getMessage());
e.printStackTrace();
}
}
Code for create a Job:
public Job createJobForuploadCrashReport(FirebaseJobDispatcher dispatcher, Bundle serviceBundle) {
Logs.i(TAG, "createJobForuploadCrashReport");
Job job = dispatcher.newJobBuilder()
.setLifetime(Lifetime.FOREVER)
.setService(UploadApkCrashReportService.class)
.setTag(mAppName + mModuleName)
.setReplaceCurrent(false)
.setRecurring(false)
.setTrigger(Trigger.executionWindow(0, 30))
.setRetryStrategy(RetryStrategy.DEFAULT_LINEAR)
.setConstraints(Constraint.ON_ANY_NETWORK)
.setExtras(serviceBundle)
.build();
return job;
}
Thanks in advance.
I have found the problem on the same day but I was quite busy.i am changing my Simple Service to JobService. The problem is in passing a Bundle to my JobService. My JobService is not able to do so much task as I am creating and sending the crash file to the server. But, Service is not able to handle so much after an application crash. The only difference is Simple Service is able to perform the same task after an application crash.