0

I already used Android Job library for schedule job but Once Google announced Workmanager library in I/O 2018 . I want to use it as alternative but unfortunately I couldn't use it to schedule notification at specific time like - for example - event notification at 8:30 am This is my workmanager request code

Data data = new Data.Builder()
                        .putString("EVENT_ID", event.id)
                        .putString("EVENT_TITLE", event.eventTitle)
                        .putString("START_TIME", event.startTime)
                        .build();

                long delayToPass = getTriggerTime(triggerTime);

                OneTimeWorkRequest compressionWork = new OneTimeWorkRequest.Builder(EventWorker.class)
                                .setInputData(data)
                                .setPeriodStartTime(delayToPass, TimeUnit.MILLISECONDS )
                                .build();

                WorkManager.getInstance().enqueue(compressionWork);

my code read trigger time from database .. I want to run notification at trigger time in database when Event occur via Workmanager library

amralsaidy
  • 183
  • 1
  • 15

2 Answers2

1

WorkManager is not designed for that scenario. You would have to use AlarmManager.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

Thanks, but I already use Evernote Android Job library to achive this scenario . but I read this next quote in their github readme

WorkManager is a new architecture component from Google and tries to solve a very similar problem this library tries to solve: implementing background jobs only once for all Android versions. The API is very similar to this library, but provides more features like chaining work items and it runs its own executor. If you start a new project, you should be using WorkManager instead of this library. You should also start migrating your code from this library to WorkManager. At some point in the future this library will be deprecated. Starting with version 1.3.0 this library will use the WorkManager internally for scheduling jobs. That should ease the transition to the new architecture component

I want to know what it means?

amralsaidy
  • 183
  • 1
  • 15