本文整理了Java中com.google.android.gms.tasks.Task.continueWith()
方法的一些代码示例,展示了Task.continueWith()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.continueWith()
方法的具体详情如下:
包路径:com.google.android.gms.tasks.Task
类名称:Task
方法名:continueWith
暂无
代码示例来源:origin: chat-sdk/chat-sdk-android
FirebaseFunctions.getInstance().getHttpsCallable("pushToChannels").call(data).continueWith((Continuation<HttpsCallableResult, String>) task -> {
if(task.getException() != null) {
Timber.d(task.getException());
代码示例来源:origin: gsuitedevs/android-samples
GoogleSignIn.getClient(mContext, signInOptionsBuilder.build());
signInClient.silentSignIn()
.continueWith(mExecutorService,
(Continuation<GoogleSignInAccount, Void>) signInTask -> {
mDriveResourceClient = Drive.getDriveResourceClient(
代码示例来源:origin: AmazMod/AmazMod
public Task<Void> syncSettings(final SettingsData settingsData) {
final TaskCompletionSource<Void> taskCompletionSource = new TaskCompletionSource<>();
getServiceInstance().continueWith(new Continuation<TransportService, Object>() {
@Override
public Object then(@NonNull Task<TransportService> task) throws Exception {
if (task.getResult() != null)
task.getResult().send(Transport.SYNC_SETTINGS, settingsData, taskCompletionSource);
return null;
}
});
return taskCompletionSource.getTask();
}
代码示例来源:origin: AmazMod/AmazMod
public Task<Void> postNotification(final NotificationData notificationData) {
final TaskCompletionSource<Void> taskCompletionSource = new TaskCompletionSource<>();
getServiceInstance().continueWith(new Continuation<TransportService, Object>() {
@Override
public Object then(@NonNull Task<TransportService> task) throws Exception {
if (task.getResult() != null)
task.getResult().send(Transport.INCOMING_NOTIFICATION, notificationData, taskCompletionSource);
return null;
}
});
return taskCompletionSource.getTask();
}
代码示例来源:origin: AmazMod/AmazMod
public Task<Void> revokeAdminOwner() {
final TaskCompletionSource<Void> taskCompletionSource = new TaskCompletionSource<>();
getServiceInstance().continueWith(new Continuation<TransportService, Object>() {
@Override
public Object then(@NonNull Task<TransportService> task) throws Exception {
if (task.getResult() != null)
task.getResult().send(Transport.REVOKE_ADMIN_OWNER, null, taskCompletionSource);
return null;
}
});
return taskCompletionSource.getTask();
}
代码示例来源:origin: AmazMod/AmazMod
public Task<Void> setBrightness(final BrightnessData brightnessData) {
final TaskCompletionSource<Void> taskCompletionSource = new TaskCompletionSource<>();
getServiceInstance().continueWith(new Continuation<TransportService, Object>() {
@Override
public Object then(@NonNull Task<TransportService> task) throws Exception {
if (task.getResult() != null)
task.getResult().send(Transport.BRIGHTNESS, brightnessData, taskCompletionSource);
return null;
}
});
return taskCompletionSource.getTask();
}
代码示例来源:origin: AmazMod/AmazMod
public Task<Void> enableLowPower() {
final TaskCompletionSource<Void> taskCompletionSource = new TaskCompletionSource<>();
getServiceInstance().continueWith(new Continuation<TransportService, Object>() {
@Override
public Object then(@NonNull Task<TransportService> task) throws Exception {
if (task.getResult() != null)
task.getResult().send(Transport.ENABLE_LOW_POWER, null, taskCompletionSource);
return null;
}
});
return taskCompletionSource.getTask();
}
代码示例来源:origin: gsuitedevs/android-samples
/**
* Gets the grocery list items.
*/
private Task<Void> loadContents(DriveFile file) {
mGroceryListFile = file;
Task<DriveContents> loadTask =
getDriveResourceClient().openFile(file, DriveFile.MODE_READ_ONLY);
return loadTask.continueWith(task -> {
Log.d(TAG, "Reading file contents.");
mDriveContents = task.getResult();
InputStream inputStream = mDriveContents.getInputStream();
String groceryListStr = ConflictUtil.getStringFromInputStream(inputStream);
mEditText.setText(groceryListStr);
return null;
});
}
代码示例来源:origin: AmazMod/AmazMod
final File file = new File(filePath);
Watch.get().getStatus().continueWith(new Continuation<WatchStatus, Object>() {
@Override
public Object then(@NonNull Task<WatchStatus> task) throws Exception {
代码示例来源:origin: AmazMod/AmazMod
@Override
public void onReceive(final Context context, Intent intent) {
if (intent.getAction() == null) {
if (!Watch.isInitialized()) {
Watch.init(context);
}
Watch.get().getBatteryStatus().continueWith(new Continuation<BatteryStatus, Object>() {
@Override
public Object then(@NonNull Task<BatteryStatus> task) throws Exception {
if (task.isSuccessful()) {
BatteryStatus batteryStatus = task.getResult();
updateBattery(batteryStatus);
} else {
BatteryStatusReceiver.this.log.e(task.getException(), "failed reading battery status");
}
return null;
}
});
} else {
startBatteryReceiver(context);
}
Log.d(Constants.TAG, "BatteryStatusReceiver onReceive");
}
代码示例来源:origin: AmazMod/AmazMod
private void updateBrightness(final int value) {
BrightnessData brightnessData = new BrightnessData();
brightnessData.setLevel(value);
brightnessSeekbar.setProgress(value);
Watch.get().setBrightness(brightnessData).continueWith(new Continuation<Void, Object>() {
@Override
public Object then(@NonNull Task<Void> task) throws Exception {
if (task.isSuccessful()) {
Snacky.builder()
.setActivity(TweakingActivity.this)
.setText(R.string.brightness_applied)
.setDuration(Snacky.LENGTH_SHORT)
.build().show();
Bundle bundle = new Bundle();
bundle.putInt("value", value);
FirebaseAnalytics
.getInstance(TweakingActivity.this)
.logEvent(FirebaseEvents.TWEAKING_BRIGHTENESS_CHANGE, bundle);
} else {
Snacky.builder()
.setActivity(TweakingActivity.this)
.setText(R.string.failed_to_set_brightness)
.setDuration(Snacky.LENGTH_SHORT)
.build().show();
}
return null;
}
});
}
代码示例来源:origin: AmazMod/AmazMod
timeLastSync = System.currentTimeMillis();
Watch.get().getStatus().continueWith(new Continuation<WatchStatus, Object>() {
@Override
public Object then(@NonNull Task<WatchStatus> task) throws Exception {
代码示例来源:origin: AmazMod/AmazMod
.continueWith(new Continuation() {
@Override
public Object then(@NonNull Task task) throws Exception {
代码示例来源:origin: AmazMod/AmazMod
private void installUpload(String destPath) {
Watch.get()
.executeShellCommand(ShellCommandHelper.getApkInstall(destPath), false, true)
.continueWith(new Continuation<ResultShellCommand, Object>() {
@Override
public Object then(@NonNull Task<ResultShellCommand> task) throws Exception {
snackProgressBarManager.dismissAll();
if (task.getResult() != null)
if (task.isSuccessful() && (task.getResult().getResultShellCommandData().getResult() == 0)) {
result = INSTALL_OK;
Bundle bundle = new Bundle();
bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, "APK");
FirebaseAnalytics
.getInstance(FileOpenerActivity.this)
.logEvent(FirebaseEvents.APK_INSTALL, bundle);
} else {
SnackProgressBar snackbar = new SnackProgressBar(SnackProgressBar.TYPE_HORIZONTAL, getString(R.string.cant_start_apk_install));
snackProgressBarManager.show(snackbar, SnackProgressBarManager.LENGTH_LONG);
result = INSTALL_ERROR;
}
else {
SnackProgressBar snackbar = new SnackProgressBar(SnackProgressBar.TYPE_HORIZONTAL, getString(R.string.activity_files_file_error));
snackProgressBarManager.show(snackbar, SnackProgressBarManager.LENGTH_LONG);
result = INSTALL_ERROR;
}
showResult();
return null;
}
});
}
代码示例来源:origin: AmazMod/AmazMod
.continueWith(new Continuation<Void, Object>() {
@Override
public Object then(@NonNull Task<Void> task) throws Exception {
代码示例来源:origin: AmazMod/AmazMod
snackProgressBarManager.show(progressBar, SnackProgressBarManager.LENGTH_INDEFINITE);
Watch.get().executeShellCommand(command, true, false).continueWith(new Continuation<ResultShellCommand, Object>() {
@Override
public Object then(@NonNull Task<ResultShellCommand> task) throws Exception {
代码示例来源:origin: AmazMod/AmazMod
.continueWith(new Continuation<Directory, Object>() {
@Override
public Object then(@NonNull Task<Directory> task) throws Exception {
代码示例来源:origin: AmazMod/AmazMod
snackProgressBarManager.show(progressBar, SnackProgressBarManager.LENGTH_INDEFINITE);
Watch.get().executeShellCommand(command, false, false).continueWith(new Continuation<ResultShellCommand, Object>() {
@Override
public Object then(@NonNull Task<ResultShellCommand> task) throws Exception {
代码示例来源:origin: AmazMod/AmazMod
Watch.get()
.executeShellCommand(ShellCommandHelper.getApkInstall(fileData.getPath()))
.continueWith(new Continuation<ResultShellCommand, Object>() {
@Override
public Object then(@NonNull Task<ResultShellCommand> task) throws Exception {
代码示例来源:origin: AmazMod/AmazMod
snackProgressBarManager.show(progressBar, SnackProgressBarManager.LENGTH_INDEFINITE);
Watch.get().executeShellCommand(command, true, false).continueWith(new Continuation<ResultShellCommand, Object>() {
@Override
public Object then(@NonNull Task<ResultShellCommand> task) throws Exception {
内容来源于网络,如有侵权,请联系作者删除!