INNER CODE UNIT · Java
initialize
jamesisaac/react-native-background-task · android/src/main/java/com/jamesisaac/rnbackgroundtask/BackgroundTaskModule.java:47
public void initialize() {
Log.d(TAG, "Initializing");
super.initialize();
// Read in an existing scheduled job if there is one
Set<JobRequest> jobRequests = JobManager.instance().getAllJobRequests();
if (jobRequests.size() > 1) {
Log.w(TAG, "Found " + jobRequests.size() + " scheduled jobs, expecting 0 or 1");
}
if (!jobRequests.isEmpty()) {
mJobRequest = jobRequests.iterator().next();
}
// Hook into lifecycle events so we can tell when the application is foregrounded
ReactApplicationContext context = getReactApplicationContext();
context.addLifecycleEventListener(this);
}