本文整理汇总了Java中com.google.android.gms.gcm.GcmNetworkManager.RESULT_SUCCESS属性的典型用法代码示例。如果您正苦于以下问题:Java GcmNetworkManager.RESULT_SUCCESS属性的具体用法?Java GcmNetworkManager.RESULT_SUCCESS怎么用?Java GcmNetworkManager.RESULT_SUCCESS使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.google.android.gms.gcm.GcmNetworkManager
的用法示例。
在下文中一共展示了GcmNetworkManager.RESULT_SUCCESS属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例2: onRunTask
@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;
}
示例3: 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;
}
示例4: onRunTask
@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;
}
示例5: 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
示例6: onRunTask
@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;
}
示例7: onRunTask
@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;
}
示例8: 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;
}
}
示例9: 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;
}
}
示例10: onRunTask
@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;
}
示例11: 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;
}
}
示例12: onRunTask
@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;
}
示例13: onRunTask
@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;
}
示例14: 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;
}
示例15: 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;
}