I am creating a job service. This service will be triggered based on change in sms(sent), works fine but failed to catch some messages.
ComponentName component = new ComponentName(context, jobTest.class);
Uri uri = Uri.parse("content://sms");
JobInfo.TriggerContentUri triggerContentUri = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
triggerContentUri = new JobInfo.TriggerContentUri(uri,
JobInfo.TriggerContentUri.FLAG_NOTIFY_FOR_DESCENDANTS);
}
JobInfo.Builder builder = new
JobInfo.Builder(1, component).addTriggerContentUri(triggerContentUri);
JobScheduler jobScheduler = (JobScheduler)
context.getSystemService(Context.JOB_SCHEDULER_SERVICE);
jobScheduler.schedule(builder.build());
I am catching only sent messages through this job,When i sent multiple messages to a number, it catches only latest message.
I don't want to use foreground service.
to trigger immediately,You need to add setTriggerContentMaxDelay
JobInfo.Builder builder = new
JobInfo.Builder(1, component).addTriggerContentUri(triggerContentUri).setTriggerContentMaxDelay(0);