当前位置: 首页>>代码示例>>Java>>正文


Java FirebaseJobDispatcher.schedule方法代码示例

本文整理汇总了Java中com.firebase.jobdispatcher.FirebaseJobDispatcher.schedule方法的典型用法代码示例。如果您正苦于以下问题:Java FirebaseJobDispatcher.schedule方法的具体用法?Java FirebaseJobDispatcher.schedule怎么用?Java FirebaseJobDispatcher.schedule使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.firebase.jobdispatcher.FirebaseJobDispatcher的用法示例。


在下文中一共展示了FirebaseJobDispatcher.schedule方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scheduleJob

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
private static boolean scheduleJob(Context context) {
    FirebaseJobDispatcher dispatcher = getDispatcher(context);
    Job job = dispatcher.newJobBuilder()
            .setService(UploadService.class)
            .setTag(context.getPackageName() + ".uploadqueue")
            .setConstraints(Constraint.ON_ANY_NETWORK)
            .setTrigger(Trigger.NOW)
            .setLifetime(Lifetime.FOREVER)
            .setRecurring(false)
            .setReplaceCurrent(true)
            .build();
    int result = dispatcher.schedule(job);
    if (result == FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS) {
        Logger.v("Job scheduled");
        return true;
    } else {
        Logger.v("Job not scheduled");
        return false;
    }
}
 
开发者ID:Nuvoex,项目名称:async-file-uploader,代码行数:21,代码来源:UploadQueue.java

示例2: scheduleFirebaseJobDispatcherSync

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
static void scheduleFirebaseJobDispatcherSync(@NonNull final Context context) {

        Driver driver = new GooglePlayDriver(context);
        FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);

        /* Create the Job to periodically sync Sunshine */
        Job syncSunshineJob = dispatcher.newJobBuilder()
                .setService(NewsFirebaseJobService.class)
                .setTag(NEWS_SYNC_TAG)
                .setConstraints(Constraint.ON_ANY_NETWORK)
                .setLifetime(Lifetime.FOREVER)
                .setRecurring(true)
                .setTrigger(Trigger.executionWindow(
                        REMINDER_INTERVAL_SECONDS,
                        REMINDER_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
                .setReplaceCurrent(true)
                .build();

        dispatcher.schedule(syncSunshineJob);
    }
 
开发者ID:vikasdesale,项目名称:News24x7-news-from-every-part-of-the-world,代码行数:21,代码来源:NewsSyncUtils.java

示例3: getNewLevelsSetup

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
synchronized public static void getNewLevelsSetup(@NonNull final Context context) {

        if (sInitialized){
            return;
        }

        Driver driver = new GooglePlayDriver(context);
        FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);

        /* Create the Job to periodically create reminders to drink water */
        Job constraintReminderJob = dispatcher.newJobBuilder()
                /* The Service that will be used to write to preferences */
                .setService(GetLastStatusJobService.class)
                /* Set the tag used to identify this Job. */
                .setTag(SCHEDULER_JOB_TAG)
                /* Live forever */
                .setLifetime(Lifetime.FOREVER)
                /* We want these reminders to continuously happen, so we tell this Job to recur. */
                .setRecurring(true)
                /* Trigger */
                .setTrigger(Trigger.executionWindow(
                        REMINDER_INTERVAL_SECONDS,
                        SYNC_FLEXTIME_SECONDS))
                /*
                 * If a Job with the tag with provided already exists, this new job will replace
                 * the old one.
                 */
                .setReplaceCurrent(true)
                /* Once the Job is ready, call the builder's build method to return the Job */
                .build();

        /* Schedule the Job with the dispatcher */
        dispatcher.schedule(constraintReminderJob);

        /* The job has been initialized */
        sInitialized = true;
    }
 
开发者ID:medialab-prado,项目名称:puremadrid,代码行数:38,代码来源:JobSchedulerHelper.java

示例4: scheduleChargingReminder

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
synchronized public static void scheduleChargingReminder(@NonNull final Context context) {

        // COMPLETED (17) If the job has already been initialized, return
        if (sInitialized) return;

        // COMPLETED (18) Create a new GooglePlayDriver
        Driver driver = new GooglePlayDriver(context);
        // COMPLETED (19) Create a new FirebaseJobDispatcher with the driver
        FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);

        // COMPLETED (20) Use FirebaseJobDispatcher's newJobBuilder method to build a job which:
        // - has WaterReminderFirebaseJobService as it's service
        // - has the tag REMINDER_JOB_TAG
        // - only triggers if the device is charging
        // - has the lifetime of the job as forever
        // - has the job recur
        // - occurs every 15 minutes with a window of 15 minutes. You can do this using a
        //   setTrigger, passing in a Trigger.executionWindow
        // - replaces the current job if it's already running
        // Finally, you should build the job.
        Job constraintReminderJob = dispatcher.newJobBuilder()
                .setService(WaterReminderFirebaseJobService.class)
                .setTag(REMINDER_JOB_TAG)
                .setConstraints(Constraint.DEVICE_CHARGING)
                .setLifetime(Lifetime.FOREVER)
                .setRecurring(true)
                .setTrigger(Trigger.executionWindow(
                        REMINDER_INTERVAL_SECONDS,
                        REMINDER_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
                .setReplaceCurrent(true)
                .build();

        // COMPLETED (21) Use dispatcher's schedule method to schedule the job
        dispatcher.schedule(constraintReminderJob);

        // COMPLETED (22) Set sInitialized to true to mark that we're done setting up the job
        sInitialized = true;
    }
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:39,代码来源:ReminderUtilities.java

示例5: scheduleJob

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
private void scheduleJob(Map<String, String> data) {
    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));

    Bundle extras = new Bundle();
    //Completa los extras con la información contenida en el mensaje
    extras.putString("data", data.get("algunDato"));

    Job myJob = dispatcher.newJobBuilder()
            .setService(MyJobService.class)
            .setTag("my-job-tag")
            .setExtras(extras)
            .build();

    dispatcher.schedule(myJob);
}
 
开发者ID:UTN-FRBA-Mobile,项目名称:Clases-2017c1,代码行数:16,代码来源:MyFirebaseMessagingService.java

示例6: scheduleJob

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
/**
 * Schedule a job using FirebaseJobDispatcher.
 */
private void scheduleJob() {
    // [START dispatch_job]
    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
    Job myJob = dispatcher.newJobBuilder()
            .setService(MyJobService.class)
            .setTag("my-job-tag")
            .build();
    dispatcher.schedule(myJob);
    // [END dispatch_job]
}
 
开发者ID:firebase,项目名称:quickstart-android,代码行数:14,代码来源:MyFirebaseMessagingService.java

示例7: setup

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
private static boolean setup(@NonNull final Context context, final int timeInSeconds, final boolean waitUnmeteredNetwork) {
    if (!isBackupActive(context)) {
        return false;
    }

    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));

    Job.Builder obBuilder = dispatcher.newJobBuilder()
            // the JobService that will be called
            .setService(DriveBackupService.class)
            // uniquely identifies the job
            .setTag(DriveBackupService.TAG)
            // one-off job
            .setRecurring(false)
            // persist past a device reboot (requires boot receiver permission)
            .setLifetime(Lifetime.FOREVER)
            // overwrite an existing job with the same tag
            .setReplaceCurrent(true)
            // retry with exponential backoff
            .setRetryStrategy(RetryStrategy.DEFAULT_LINEAR);

    if (waitUnmeteredNetwork) {
        // only run on an unmetered network
        obBuilder.addConstraint(Constraint.ON_UNMETERED_NETWORK);
    }

    if (timeInSeconds >= 0) {
        // Run after selected time and any time in one hour
        obBuilder.setTrigger(Trigger.executionWindow(timeInSeconds, timeInSeconds + 1800));
    } else {
        obBuilder.setTrigger(Trigger.NOW);
    }

    return dispatcher.schedule(obBuilder.build()) == FirebaseJobDispatcher.SCHEDULE_RESULT_SUCCESS;
}
 
开发者ID:canyapan,项目名称:DietDiaryApp,代码行数:36,代码来源:DriveBackupServiceHelper.java

示例8: scheduleJob

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
/**
 * Schedule a job using FirebaseJobDispatcher.     so if longer then 10 seconds, schedule the job.
 */
private void scheduleJob() {
    // [START dispatch_job]
    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(this));
    Job myJob = dispatcher.newJobBuilder()
        .setService(MyJobService.class)
        .setTag("my-job-tag")
        .build();
    dispatcher.schedule(myJob);
    // [END dispatch_job]
}
 
开发者ID:JimSeker,项目名称:googleplayAPI,代码行数:14,代码来源:MyFirebaseMessagingService.java

示例9: scheduleFirebaseJobDispatcherSync

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
/**
 * Schedules a repeating sync of Sunshine's weather data using FirebaseJobDispatcher.
 * @param context Context used to create the GooglePlayDriver that powers the
 *                FirebaseJobDispatcher
 */
static void scheduleFirebaseJobDispatcherSync(@NonNull final Context context) {

    Driver driver = new GooglePlayDriver(context);
    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);

    /* Create the Job to periodically sync Sunshine */
    Job syncSunshineJob = dispatcher.newJobBuilder()
            /* The Service that will be used to sync Sunshine's data */
            .setService(SunshineFirebaseJobService.class)
            /* Set the UNIQUE tag used to identify this Job */
            .setTag(SUNSHINE_SYNC_TAG)
            /*
             * Network constraints on which this Job should run. We choose to run on any
             * network, but you can also choose to run only on un-metered networks or when the
             * device is charging. It might be a good idea to include a preference for this,
             * as some users may not want to download any data on their mobile plan. ($$$)
             */
            .setConstraints(Constraint.ON_ANY_NETWORK)
            /*
             * setLifetime sets how long this job should persist. The options are to keep the
             * Job "forever" or to have it die the next time the device boots up.
             */
            .setLifetime(Lifetime.FOREVER)
            /*
             * We want Sunshine's weather data to stay up to date, so we tell this Job to recur.
             */
            .setRecurring(true)
            /*
             * We want the weather data to be synced every 3 to 4 hours. The first argument for
             * Trigger's static executionWindow method is the start of the time frame when the
             * sync should be performed. The second argument is the latest point in time at
             * which the data should be synced. Please note that this end time is not
             * guaranteed, but is more of a guideline for FirebaseJobDispatcher to go off of.
             */
            .setTrigger(Trigger.executionWindow(
                    SYNC_INTERVAL_SECONDS,
                    SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
            /*
             * If a Job with the tag with provided already exists, this new job will replace
             * the old one.
             */
            .setReplaceCurrent(true)
            /* Once the Job is ready, call the builder's build method to return the Job */
            .build();

    /* Schedule the Job with the dispatcher */
    dispatcher.schedule(syncSunshineJob);
}
 
开发者ID:changja88,项目名称:Android_Sunshine_Watch,代码行数:54,代码来源:SunshineSyncUtils.java

示例10: scheduleChargingReminder

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
synchronized public static void scheduleChargingReminder(@NonNull final Context context) {

        if (sInitialized) return;

        Driver driver = new GooglePlayDriver(context);
        FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);

        /* Create the Job to periodically create reminders to drink water */
        Job constraintReminderJob = dispatcher.newJobBuilder()
                /* The Service that will be used to write to preferences */
                .setService(WaterReminderFirebaseJobService.class)
                /*
                 * Set the UNIQUE tag used to identify this Job.
                 */
                .setTag(REMINDER_JOB_TAG)
                /*
                 * Network constraints on which this Job should run. In this app, we're using the
                 * device charging constraint so that the job only executes if the device is
                 * charging.
                 *
                 * In a normal app, it might be a good idea to include a preference for this,
                 * as different users may have different preferences on when you should be
                 * syncing your application's data.
                 */
                .setConstraints(Constraint.DEVICE_CHARGING)
                /*
                 * setLifetime sets how long this job should persist. The options are to keep the
                 * Job "forever" or to have it die the next time the device boots up.
                 */
                .setLifetime(Lifetime.FOREVER)
                /*
                 * We want these reminders to continuously happen, so we tell this Job to recur.
                 */
                .setRecurring(true)
                /*
                 * We want the reminders to happen every 15 minutes or so. The first argument for
                 * Trigger class's static executionWindow method is the start of the time frame
                 * when the
                 * job should be performed. The second argument is the latest point in time at
                 * which the data should be synced. Please note that this end time is not
                 * guaranteed, but is more of a guideline for FirebaseJobDispatcher to go off of.
                 */
                .setTrigger(Trigger.executionWindow(
                        REMINDER_INTERVAL_SECONDS,
                        REMINDER_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
                /*
                 * If a Job with the tag with provided already exists, this new job will replace
                 * the old one.
                 */
                .setReplaceCurrent(true)
                /* Once the Job is ready, call the builder's build method to return the Job */
                .build();

        /* Schedule the Job with the dispatcher */
        dispatcher.schedule(constraintReminderJob);

        /* The job has been initialized */
        sInitialized = true;
    }
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:60,代码来源:ReminderUtilities.java

示例11: scheduleFirebaseJobDispatcherSync

import com.firebase.jobdispatcher.FirebaseJobDispatcher; //导入方法依赖的package包/类
/**
 * Schedules a repeating sync of Sunshine's weather data using FirebaseJobDispatcher.
 *
 * @param context Context used to create the GooglePlayDriver that powers the
 *                FirebaseJobDispatcher
 */
static void scheduleFirebaseJobDispatcherSync(@NonNull final Context context) {

    Driver driver = new GooglePlayDriver(context);
    FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(driver);

    /* Create the Job to periodically sync Sunshine */
    Job syncSunshineJob = dispatcher.newJobBuilder()
            /* The Service that will be used to sync Sunshine's data */
            .setService(SunshineFirebaseJobService.class)
            /* Set the UNIQUE tag used to identify this Job */
            .setTag(SUNSHINE_SYNC_TAG)
            /*
             * Network constraints on which this Job should run. We choose to run on any
             * network, but you can also choose to run only on un-metered networks or when the
             * device is charging. It might be a good idea to include a preference for this,
             * as some users may not want to download any data on their mobile plan. ($$$)
             */
            .setConstraints(Constraint.ON_ANY_NETWORK)
            /*
             * setLifetime sets how long this job should persist. The options are to keep the
             * Job "forever" or to have it die the next time the device boots up.
             */
            .setLifetime(Lifetime.FOREVER)
            /*
             * We want Sunshine's weather data to stay up to date, so we tell this Job to recur.
             */
            .setRecurring(true)
            /*
             * We want the weather data to be synced every 3 to 4 hours. The first argument for
             * Trigger's static executionWindow method is the start of the time frame when the
             * sync should be performed. The second argument is the latest point in time at
             * which the data should be synced. Please note that this end time is not
             * guaranteed, but is more of a guideline for FirebaseJobDispatcher to go off of.
             */
            .setTrigger(Trigger.executionWindow(
                    SYNC_INTERVAL_SECONDS,
                    SYNC_INTERVAL_SECONDS + SYNC_FLEXTIME_SECONDS))
            /*
             * If a Job with the tag with provided already exists, this new job will replace
             * the old one.
             */
            .setReplaceCurrent(true)
            /* Once the Job is ready, call the builder's build method to return the Job */
            .build();

    /* Schedule the Job with the dispatcher */
    dispatcher.schedule(syncSunshineJob);
}
 
开发者ID:fjoglar,项目名称:android-dev-challenge,代码行数:55,代码来源:SunshineSyncUtils.java


注:本文中的com.firebase.jobdispatcher.FirebaseJobDispatcher.schedule方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。