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


Java TaskParams类代码示例

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


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

示例1: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    try {
        Bundle bundle = taskParams.getExtras();
        String taskName = bundle.getString(TaskScheduler.TASK_NAME);
        Task task = (Task) Class.forName(taskName).newInstance();
        ArrayMap<String, Object> map = new ArrayMap<>(bundle.size());
        for (String key : bundle.keySet()) {
            map.put(key, bundle.get(key));
        }
        task.deserialize(map);
        if (task.isRunning())
            return GcmNetworkManager.RESULT_RESCHEDULE;
        task.attach(null, ContextHandle.getApplicationHandle());
        task.run();
        task.deliverResult(this);
        return GcmNetworkManager.RESULT_SUCCESS;
    } catch (Exception err) {
        LOG.e("Error running task", err);
        return GcmNetworkManager.RESULT_FAILURE;
    }
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:23,代码来源:TaskGcmService.java

示例2: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    Log.i(TAG, "Backing up the account settings");

    final SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    Bundle data = new Bundle();
    data.putString(FIRST_NAME, sharedPreferences.getString(FIRST_NAME,""));
    data.putString(LAST_NAME, sharedPreferences.getString(LAST_NAME,""));
    data.putString(AGE, sharedPreferences.getString(AGE,""));
    data.putString("resource", RESOURCE);
    data.putString("operation", sharedPreferences.getString(OPERATION,""));
    String id = Integer.toString(new Random().nextInt());
    GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(MyBackupService.this);
    try {
        gcm.send(getString(R.string.gcm_SenderId) + "@gcm.googleapis.com", id, data);
    } catch (IOException e) {
        Log.e(TAG, "Failed to backup account");
        return GcmNetworkManager.RESULT_RESCHEDULE;
    }


    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:PacktPublishing,项目名称:Asynchronous-Android-Programming,代码行数:25,代码来源:MyBackupService.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 (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

示例4: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {

    Log.d(TAG, "Task uploader has started");

    // check Airplane Mode enabled
    if (ConnectionUtils.isAirplaneModeEnabled(this)) {
        Log.d(TAG, "Airplane Mode enabled. Upload request ignored");
        return GcmNetworkManager.RESULT_FAILURE;
    }

    // device is not online
    if (!ConnectionUtils.isOnline(this)) {
        Log.d(TAG, "Device is not online. Upload request ignored");
        return GcmNetworkManager.RESULT_FAILURE;
    }

    if (daoProvider == null) {
        daoProvider = DaoProvider.getInstance(getApplicationContext());
    }

    Handler handler = new Handler(getMainLooper());
    handler.post(this::prepareData);

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-client-sdk-android,代码行数:27,代码来源:LogsUploadService.java

示例5: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {

    Log.d(TAG, "PlanB task has been executed!");

    String userToken = PreferenceProvider
            .getInstance(getApplicationContext())
            .getUserToken();

    // only when user is logged in
    if (userToken != null && !userToken.isEmpty()) {

        HarvesterServiceProvider serviceProvider = HarvesterServiceProvider.getInstance(getApplicationContext());

        if (!serviceProvider.isServiceRunning()) {
            serviceProvider.startSensingService();
        }

        if (!serviceProvider.isAccessibilityServiceRunning()) {
            serviceProvider.startAccessibilityService();
        }
    }

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:Telecooperation,项目名称:assistance-platform-client-sdk-android,代码行数:26,代码来源:PlanBService.java

示例6: 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

示例7: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    if (actionRecovery != null &&
            gson != null &&
            orchextraLogger != null) {
        orchextraLogger.log("Executing Scheduled action " + taskParams.getTag());

        try {
            Bundle extras = taskParams.getExtras();
            String stringAndroidBasicAction = extras.getString(ActionsSchedulerGcmImpl.BUNDLE_TASK_PARAM_NAME);
            AndroidBasicAction androidBasicAction = gson.fromJson(stringAndroidBasicAction, AndroidBasicAction.class);
            actionRecovery.recoverAction(androidBasicAction);
            orchextraLogger.log("Scheduled action Executed and deleted " + taskParams.getTag());
            return GcmNetworkManager.RESULT_SUCCESS;
        } catch (Exception e) {
            orchextraLogger.log("Error retrieving Scheduled action", OrchextraSDKLogLevel.ERROR);
            return GcmNetworkManager.RESULT_FAILURE;
        }
    } else {
        return GcmNetworkManager.RESULT_FAILURE;
    }
}
 
开发者ID:Orchextra,项目名称:orchextra-android-sdk,代码行数:23,代码来源:OrchextraGcmTaskService.java

示例8: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    int jobId = Integer.parseInt(taskParams.getTag());
    JobProxy.Common common = new JobProxy.Common(this, CAT, jobId);

    JobRequest request = common.getPendingRequest(true, true);
    if (request == null) {
        return GcmNetworkManager.RESULT_FAILURE;
    }

    Job.Result result = common.executeJobRequest(request, taskParams.getExtras());
    if (Job.Result.SUCCESS.equals(result)) {
        return GcmNetworkManager.RESULT_SUCCESS;
    } else {
        return GcmNetworkManager.RESULT_FAILURE;
    }
}
 
开发者ID:evernote,项目名称:android-job,代码行数:18,代码来源:PlatformGcmService.java

示例9: getTaskParametersFromTaskParams

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
/**
 * Retrieves the {@link TaskParameters} from the {@link TaskParams}, which are passed as
 * one of the keys. Only values valid for {@link android.os.BaseBundle} are supported, and other
 * values are stripped at the time when the task is scheduled.
 *
 * @param taskParams the {@link TaskParams} to extract the {@link TaskParameters} from.
 * @return the {@link TaskParameters} for the current job.
 */
static TaskParameters getTaskParametersFromTaskParams(@NonNull TaskParams taskParams) {
    int taskId;
    try {
        taskId = Integer.parseInt(taskParams.getTag());
    } catch (NumberFormatException e) {
        Log.e(TAG, "Cound not parse task ID from task tag: " + taskParams.getTag());
        return null;
    }

    TaskParameters.Builder builder = TaskParameters.create(taskId);

    Bundle extras = taskParams.getExtras();
    Bundle taskExtras = extras.getBundle(BACKGROUND_TASK_EXTRAS_KEY);
    builder.addExtras(taskExtras);

    return builder.build();
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:26,代码来源:BackgroundTaskSchedulerGcmNetworkManager.java

示例10: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {

    Injector.inject(this);

    Ln.v("Syncing Data");

    m_accountUtils.refreshAuthToken(new AccountUtils.TokenRefreshListener() {
        @Override
        public void onTokenRefreshed() {
            hasToken = true;
            m_smartListService.synchronizeSmartLists();
        }

        @Override
        public void onTokenError() {
            hasToken = false;
        }
    });

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:johncarpenter,项目名称:MarketAndroid,代码行数:23,代码来源:ManualSyncService.java

示例11: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    try {
        if (taskParams.getTag().equals(AUTO_UPDATE_TASK_NAME)) {
            Timber.d("GCM invoked update task");
            IBurnService service = new IBurnService(getApplicationContext());
            boolean success = service.updateData().blockingGet();
            Timber.d("GCM invoked task finished with success %b", success);
            return success ? GcmNetworkManager.RESULT_SUCCESS : GcmNetworkManager.RESULT_RESCHEDULE;
        }
        Timber.w("Unknown task (%s) invoked", taskParams.getTag());
        return GcmNetworkManager.RESULT_FAILURE;
    } catch (Exception e) {
        ExceptionHandler.saveException(e, null);
        Timber.e(e, "GCM task failed: %s", e.getClass().getSimpleName());
        return GcmNetworkManager.RESULT_RESCHEDULE;
    }
}
 
开发者ID:Burning-Man-Earth,项目名称:iBurn-Android,代码行数:19,代码来源:DataUpdateService.java

示例12: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    Intent i = new Intent();
    i.setPackage(getPackageName());
    i.setAction(CastServiceConstants.ACTION_MEDIA_COMMAND);
    i.putExtra(CastServiceConstants.EXTRA_COMMAND, CastServiceConstants.COMMAND_NEXT);
    // This should work since GcmTaskService should be in foreground, and it service
    // should be previously created
    startService(i);

    // Hold a bit the job, to ensure the picture was sent over the network
    try {
        synchronized (mNetworkLock) {
            mNetworkLock.wait(MAX_NETWORK_WAIT);
        }
    } catch (InterruptedException ex) {
        // Ignore
    }

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:jruesga,项目名称:PhotoPhase,代码行数:22,代码来源:CastGcmTaskService.java

示例13: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    Log.i(TAG, "onRunTask");
    Intent start = new Intent(this, TrackerActivity.class);
    start.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(start);
    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:ayushghd,项目名称:iSPY,代码行数:9,代码来源:TrackerTaskService.java

示例14: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    try {
        final AccountModel accountModel = new AccountModel();
        final List<Account> accounts = accountModel.accounts().toBlocking().first();

        for (Account account : accounts) {
            final UserModel userModel = new UserModel(account, account.screenName());
            final User user = userModel.user().toBlocking().first();

            final Account updatedAccount = account.withMeta(
                    user.getName(),
                    user.getScreenName(),
                    user.getOriginalProfileImageURL(),
                    user.getProfileBannerMobileRetinaURL()
            );

            accountModel.update(updatedAccount).toBlocking().first();
            new ContactModel(account).update().toBlocking().first();
        }

        return GcmNetworkManager.RESULT_SUCCESS;
    } catch (Throwable t) {
        Timber.i(t, "");
    }

    return GcmNetworkManager.RESULT_FAILURE;
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:29,代码来源:AccountUpdateService.java

示例15: onRunTask

import com.google.android.gms.gcm.TaskParams; //导入依赖的package包/类
@Override
public int onRunTask(TaskParams taskParams) {
    try {
        final PrefsModel prefsModel = new PrefsModel();

        for (final Account account : new AccountModel().accounts().toBlocking().first()) {
            new TimelineModel(account, TimelineModel.HOME_ID).update().toBlocking().first();
            new TimelineModel(account, TimelineModel.RETWEETS_ID).update().toBlocking().first();
            new TimelineModel(account, TimelineModel.FAVORITES_ID).update().toBlocking().first();
            new UserListsModel(account).update().toBlocking().first();
            new DirectsModel(account).update().toBlocking().first();

            List<UserList> userLists = new UserListsModel(account).lists().toBlocking().first();
            for (UserList userList : userLists)
                new TimelineModel(account, userList.listId()).update().toBlocking().first();

            new TimelineModel(account, TimelineModel.MENTIONS_ID)
                    .update()
                    .subscribeOn(Schedulers.io())
                    .observeOn(AndroidSchedulers.mainThread())
                    .subscribe(new DefaultObserver<Integer>() {
                        @Override
                        public void onNext(Integer newMentionCount) {
                            super.onNext(newMentionCount);
                            if (prefsModel.isNotificationsEnabled() && newMentionCount > 0) {
                                notifyMentions(account, newMentionCount);
                            }
                        }
                    });
        }

        return GcmNetworkManager.RESULT_SUCCESS;
    } catch (Throwable t) {
        Timber.i(t, "");
    }

    return GcmNetworkManager.RESULT_FAILURE;
}
 
开发者ID:mecid,项目名称:robird-reborn,代码行数:39,代码来源:TimelineUpdateService.java


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