示例#1
0
  public <T extends Parcelable> T getAttribute(String type) {
    final IDroneApi droneApi = droneApiRef.get();
    if (!isStarted(droneApi) || type == null) return this.getAttributeDefaultValue(type);

    T attribute = null;
    Bundle carrier = null;
    try {
      carrier = droneApi.getAttribute(type);
    } catch (RemoteException e) {
      handleRemoteException(e);
    }

    if (carrier != null) {
      try {
        carrier.setClassLoader(contextClassLoader);
        attribute = carrier.getParcelable(type);
      } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
      }
    }

    return attribute == null ? this.<T>getAttributeDefaultValue(type) : attribute;
  }