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


Java GcmNetworkManager.RESULT_FAILURE属性代码示例

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


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

示例1: onRunTask

@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,代码行数:22,代码来源:TaskGcmService.java

示例2: fetchUrl

private int fetchUrl(OkHttpClient client, String url) {
    Request request = new Request.Builder()
            .url(url)
            .build();

    try {
        Response response = client.newCall(request).execute();
        Log.d(TAG, "fetchUrl:response:" + response.body().string());

        if (response.code() != 200) {
            return GcmNetworkManager.RESULT_FAILURE;
        }
    } catch (IOException e) {
        Log.e(TAG, "fetchUrl:error" + e.toString());
        return GcmNetworkManager.RESULT_FAILURE;
    }

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:googlesamples,项目名称:android-gcmnetworkmanager,代码行数:19,代码来源:MyTaskService.java

示例3: onRunTask

@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,代码行数:26,代码来源:LogsUploadService.java

示例4: onRunTask

@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,代码行数:22,代码来源:OrchextraGcmTaskService.java

示例5: onRunTask

@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,代码行数:17,代码来源:PlatformGcmService.java

示例6: onRunTask

@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,代码行数:18,代码来源:DataUpdateService.java

示例7: onRunTask

@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,代码行数:28,代码来源:AccountUpdateService.java

示例8: onRunTask

@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,代码行数:38,代码来源:TimelineUpdateService.java

示例9: onRunTask

@Override
public int onRunTask(TaskParams taskParams) {
    String taskId = taskParams.getExtras().getString(CodelabUtil.TASK_ID);
    boolean completed = CodelabUtil.makeNetworkCall();

    Log.d(TAG, "Oneoff scheduled call executed. Task ID: " + taskId);

    // Prepare Intent to send with broadcast.
    Intent taskUpdateIntent = new Intent(CodelabUtil.TASK_UPDATE_FILTER);
    taskUpdateIntent.putExtra(CodelabUtil.TASK_ID, taskId);
    TaskItem taskItem = CodelabUtil.getTaskItemFromFile(this, taskId);
    if (taskItem == null) {
        return GcmNetworkManager.RESULT_FAILURE;
    }
    if (completed) {
        taskItem.setStatus(TaskItem.EXECUTED_STATUS);
    } else {
        taskItem.setStatus(TaskItem.FAILED_STATUS);
    }
    taskUpdateIntent.putExtra(CodelabUtil.TASK_STATUS, taskItem.getStatus());
    CodelabUtil.saveTaskItemToFile(this, taskItem);

    // Notify listeners (MainActivity) that task was completed successfully.
    LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this);
    localBroadcastManager.sendBroadcast(taskUpdateIntent);
    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:googlecodelabs,项目名称:android-network-manager,代码行数:27,代码来源:BestTimeService.java

示例10: onRunTask

@Override
public int onRunTask(TaskParams params) {
    final BackgroundTask backgroundTask =
            BackgroundTaskSchedulerGcmNetworkManager.getBackgroundTaskFromTaskParams(params);
    if (backgroundTask == null) {
        Log.w(TAG, "Failed to start task. Could not instantiate class.");
        return GcmNetworkManager.RESULT_FAILURE;
    }

    final TaskParameters taskParams =
            BackgroundTaskSchedulerGcmNetworkManager.getTaskParametersFromTaskParams(params);
    final Waiter waiter = new Waiter(Waiter.MAX_TIMEOUT_SECONDS);

    final AtomicBoolean taskNeedsBackgroundProcessing = new AtomicBoolean();
    ThreadUtils.runOnUiThreadBlocking(new Runnable() {
        @Override
        public void run() {
            taskNeedsBackgroundProcessing.set(
                    backgroundTask.onStartTask(ContextUtils.getApplicationContext(), taskParams,
                            new TaskFinishedCallbackGcmTaskService(waiter)));
        }
    });

    if (!taskNeedsBackgroundProcessing.get()) return GcmNetworkManager.RESULT_SUCCESS;

    waiter.startWaiting();

    if (waiter.isRescheduleNeeded()) return GcmNetworkManager.RESULT_RESCHEDULE;
    if (!waiter.hasTaskTimedOut()) return GcmNetworkManager.RESULT_SUCCESS;

    final AtomicBoolean taskNeedsRescheduling = new AtomicBoolean();
    ThreadUtils.runOnUiThreadBlocking(new Runnable() {
        @Override
        public void run() {
            taskNeedsRescheduling.set(backgroundTask.onStopTask(
                    ContextUtils.getApplicationContext(), taskParams));
        }
    });

    if (taskNeedsRescheduling.get()) return GcmNetworkManager.RESULT_RESCHEDULE;

    return GcmNetworkManager.RESULT_SUCCESS;
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:43,代码来源:BackgroundTaskGcmTaskService.java


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