com.google.android.gms.tasks.Task.getResult()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.0k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中com.google.android.gms.tasks.Task.getResult()方法的一些代码示例,展示了Task.getResult()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Task.getResult()方法的具体详情如下:
包路径:com.google.android.gms.tasks.Task
类名称:Task
方法名:getResult

Task.getResult介绍

暂无

代码示例

代码示例来源:origin: commonsguy/cw-omnibus

private void useResult(Task<Location> task) {
 if (task.getResult()==null) {
  Toast
   .makeText(this, R.string.msg_no_location, Toast.LENGTH_LONG)
   .show();
  finish();
 }
 else {
  fragment.fetchForecast(task.getResult());
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void handleSettingsResponse(Task<LocationSettingsResponse> task) {
 try {
  LocationSettingsResponse response=task.getResult(ApiException.class);
  LocationSettingsStates states=response.getLocationSettingsStates();
  if (states.isLocationPresent() && states.isLocationUsable()) {
   findLocation();
  }
  else {
   unavailable();
  }
 }
 catch (ApiException e) {
  copeWithFailure(e);
 }
}

代码示例来源:origin: commonsguy/cw-omnibus

private void handleSettingsResponse(Task<LocationSettingsResponse> task) {
 try {
  LocationSettingsResponse response=task.getResult(ApiException.class);
  LocationSettingsStates states=response.getLocationSettingsStates();
  if (states.isLocationPresent() && states.isLocationUsable()) {
   findLocation();
  }
  else {
   unavailable();
  }
 }
 catch (ApiException e) {
  copeWithFailure(e);
 }
}

代码示例来源:origin: googlemaps/android-samples

@Override
  public void onComplete(@NonNull Task<Location> task) {
    if (task.isSuccessful()) {
      // Set the map's camera position to the current location of the device.
      mLastKnownLocation = task.getResult();
      mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(
          new LatLng(mLastKnownLocation.getLatitude(),
              mLastKnownLocation.getLongitude()), DEFAULT_ZOOM));
    } else {
      Log.d(TAG, "Current location is null. Using defaults.");
      Log.e(TAG, "Exception: %s", task.getException());
      mMap.moveCamera(CameraUpdateFactory
          .newLatLngZoom(mDefaultLocation, DEFAULT_ZOOM));
      mMap.getUiSettings().setMyLocationButtonEnabled(false);
    }
  }
});

代码示例来源:origin: chat-sdk/chat-sdk-android

Timber.d(task.getResult().getData().toString());

代码示例来源:origin: googlemaps/android-samples

@Override
public void onComplete(@NonNull Task<PlaceLikelihoodBufferResponse> task) {
  if (task.isSuccessful() && task.getResult() != null) {
    PlaceLikelihoodBufferResponse likelyPlaces = task.getResult();

代码示例来源:origin: AmazMod/AmazMod

@Override
  public Object then(@NonNull Task<TransportService> task) throws Exception {
    if (task.getResult() != null)
      task.getResult().send(Transport.BRIGHTNESS, brightnessData, taskCompletionSource);
    return null;
  }
});

代码示例来源:origin: AmazMod/AmazMod

@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;
  }
});

代码示例来源:origin: AmazMod/AmazMod

@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;
  }
});

代码示例来源:origin: AmazMod/AmazMod

@Override
  public Task<Directory> then(@NonNull Task<TransportService> task) throws Exception {
    return Objects.requireNonNull(task.getResult()).sendWithResult(Transport.REQUEST_DIRECTORY, Transport.DIRECTORY, requestDirectoryData);
  }
});

代码示例来源:origin: AmazMod/AmazMod

@Override
  public Task<ResultDeleteFile> then(@NonNull Task<TransportService> task) throws Exception {
    return Objects.requireNonNull(task.getResult()).sendWithResult(Transport.REQUEST_DELETE_FILE, Transport.RESULT_DELETE_FILE, requestDeleteFileData);
  }
});

代码示例来源:origin: AmazMod/AmazMod

@Override
  public Task<ResultShellCommand> then(@NonNull Task<TransportService> task) throws Exception {
    return Objects.requireNonNull(task.getResult()).sendWithResult(Transport.REQUEST_SHELL_COMMAND, Transport.RESULT_SHELL_COMMAND, requestShellCommandData);
  }
});

代码示例来源:origin: AmazMod/AmazMod

@Override
  public Task<Watchface> then(@NonNull Task<TransportService> task) throws Exception {
    return Objects.requireNonNull(task.getResult()).sendWithResult(Transport.WATCHFACE_DATA, Transport.WATCHFACE_DATA, watchfaceData);
  }
});

代码示例来源:origin: firebase/snippets-android

@Override
  public void onComplete(@NonNull Task<ShortDynamicLink> task) {
    if (task.isSuccessful()) {
      // Short link created
      Uri shortLink = task.getResult().getShortLink();
      Uri flowchartLink = task.getResult().getPreviewLink();
    } else {
      // Error
      // ...
    }
  }
});

代码示例来源:origin: firebase/snippets-android

@Override
  public void onComplete(@NonNull Task<ShortDynamicLink> task) {
    if (task.isSuccessful()) {
      // Short link created
      Uri shortLink = task.getResult().getShortLink();
      Uri flowchartLink = task.getResult().getPreviewLink();
    } else {
      // Error
      // ...
    }
  }
});

代码示例来源:origin: IBM/android-kubernetes-blockchain

@Override
  public void onComplete(@NonNull Task<Boolean> task) {
    if (task.isSuccessful() && task.getResult()) {
      Log.d(TAG, "Step Listener for steps was removed.");
    } else {
      Log.e(TAG, "Step Listener for steps was not removed.", task.getException());
    }
  }
}

代码示例来源:origin: akshayejh/PhotoBlog-Android-Blog-App

@Override
  public void onComplete(@NonNull Task<DocumentSnapshot> task) {
    if(task.isSuccessful()){
      String userName = task.getResult().getString("name");
      String userImage = task.getResult().getString("image");
      holder.setUserData(userName, userImage);
    } else {
      //Firebase Exception
    }
  }
});

代码示例来源:origin: Countly/countly-sdk-android

@Override
  public void onComplete(@NonNull Task<InstanceIdResult> task) {
    if (!task.isSuccessful()) {
      Log.w(TAG, "getInstanceId failed", task.getException());
      return;
    }
    // Get new Instance ID token
    String token = task.getResult().getToken();
    CountlyPush.onTokenRefresh(token);
  }
});

代码示例来源:origin: chat-sdk/chat-sdk-android

emitter.onSuccess(task.getResult().getUser());
} else {
  emitter.onError(task.getException());

代码示例来源:origin: codeka/wwmmo

public GmsTask(TaskRunner taskRunner, com.google.android.gms.tasks.Task<R> gmsTask) {
  super(taskRunner);
  gmsTask.addOnFailureListener(this::onError);
  gmsTask.addOnCompleteListener(task -> {
   try {
    this.onComplete(task.getResult());
   } catch (Exception e) {
    onError(e);
   }
  });
 }
}

相关文章