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


Java TaskParams.getTag方法代码示例

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


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

示例1: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入方法依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    Log.d(TAG, "onRunTask: " + taskParams.getTag());

    String tag = taskParams.getTag();

    // Default result is success.
    int result = GcmNetworkManager.RESULT_SUCCESS;

    // Choose method based on the tag.
    if (GcmActivity.TASK_TAG_UNMETERED.equals(tag)) {
        result = doUnmeteredTask();
    } else if (GcmActivity.TASK_TAG_CHARGING.equals(tag)) {
        result = doChargingTask();
    }
    // Return one of RESULT_SUCCESS, RESULT_FAILURE, or RESULT_RESCHEDULE
    return result;
}
 
开发者ID:NightscoutFoundation,项目名称:xDrip,代码行数:19,代码来源:TaskService.java

示例2: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入方法依赖的package包/类
@Override
public int onRunTask(TaskParams params) {
    String tag = params.getTag();
    TaskCollection tasks = TaskCollection.getInstance(this);
    TaskTracker task = tasks.getTask(tag);
    if (task != null) {
        task.execute(mLogger);
        tasks.updateTask(task);
    } else {
        mLogger.log(Log.ERROR, "Could not find task with tag " + tag);
        task = TaskTracker.emptyTaskWithTag(tag);
        task.execute(mLogger);
        tasks.updateTask(task);
    }
    return GcmNetworkManager.RESULT_SUCCESS;

}
 
开发者ID:google,项目名称:gcm,代码行数:18,代码来源:TaskSchedulerService.java

示例3: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入方法依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    Log.d(TAG, "onRunTask: " + taskParams.getTag());

    String tag = taskParams.getTag();

    // Default result is success.
    int result = GcmNetworkManager.RESULT_SUCCESS;

    // Choose method based on the tag.
    if (MainActivity.TASK_TAG_WIFI.equals(tag)) {
        result = doWifiTask();
    } else if (MainActivity.TASK_TAG_CHARGING.equals(tag)) {
        result = doChargingTask();
    } else if (MainActivity.TASK_TAG_PERIODIC.equals(tag)) {
        result = doPeriodicTask();
    }

    // Create Intent to broadcast the task information.
    Intent intent = new Intent();
    intent.setAction(ACTION_DONE);
    intent.putExtra(EXTRA_TAG, tag);
    intent.putExtra(EXTRA_RESULT, result);

    // Send local broadcast, running Activities will be notified about the task.
    LocalBroadcastManager manager = LocalBroadcastManager.getInstance(this);
    manager.sendBroadcast(intent);

    // Return one of RESULT_SUCCESS, RESULT_FAILURE, or RESULT_RESCHEDULE
    return result;
}
 
开发者ID:googlesamples,项目名称:android-gcmnetworkmanager,代码行数:32,代码来源:MyTaskService.java

示例4: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入方法依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    switch (taskParams.getTag()) {
        case MY_TASK:
            //task code...
            return GcmNetworkManager.RESULT_SUCCESS;
    }
    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:PacktPublishing,项目名称:Android-High-Performance-Programming,代码行数:10,代码来源:MyGcmTaskService.java

示例5: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入方法依赖的package包/类
@Override
@VisibleForTesting
public int onRunTask(final TaskParams params) {
    final String taskTag = params.getTag();
    Log.i(TAG, "[" + taskTag + "] Woken up at " + new java.util.Date().toString());
    final ChromeBackgroundServiceWaiter waiter = getWaiterIfNeeded(params.getExtras());
    final Context context = this;
    ThreadUtils.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            switch (taskTag) {
                case BackgroundSyncLauncher.TASK_TAG:
                    handleBackgroundSyncEvent(context, taskTag);
                    break;

                case OfflinePageUtils.TASK_TAG:
                    handleOfflinePageBackgroundLoad(
                            context, params.getExtras(), waiter, taskTag);
                    break;

                case SnippetsLauncher.TASK_TAG_WIFI:
                case SnippetsLauncher.TASK_TAG_FALLBACK:
                    handleFetchSnippets(context, taskTag);
                    break;

                case PrecacheController.PERIODIC_TASK_TAG:
                case PrecacheController.CONTINUATION_TASK_TAG:
                    handlePrecache(context, taskTag);
                    break;

                case DownloadResumptionScheduler.TASK_TAG:
                    DownloadResumptionScheduler.getDownloadResumptionScheduler(
                            context.getApplicationContext()).handleDownloadResumption();
                    break;

                default:
                    Log.i(TAG, "Unknown task tag " + taskTag);
                    break;
            }
        }
    });
    // If needed, block the GcmNetworkManager thread until the UI thread has finished its work.
    waitForTaskIfNeeded(waiter);

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:47,代码来源:ChromeBackgroundService.java


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