本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}