Package 

Class AndroidChannelBuilder


  • 
    public final class AndroidChannelBuilder
    extends ForwardingChannelBuilder<AndroidChannelBuilder>
                        

    Builds a ManagedChannel that, when provided with a Context, will automatically monitor the Android device's network state to smoothly handle intermittent network failures.

    Currently only compatible with gRPC's OkHttp transport, which must be available at runtime.

    Requires the Android ACCESS_NETWORK_STATE permission.

    • Method Summary

      Modifier and Type Method Description
      static AndroidChannelBuilder forTarget(String target) Creates a new builder with the given target string that will be resolved by io.grpc.NameResolver.
      static AndroidChannelBuilder forAddress(String name, int port) Creates a new builder with the given host and port.
      static AndroidChannelBuilder fromBuilder(ManagedChannelBuilder<out Object> builder) Creates a new builder, which delegates to the given ManagedChannelBuilder.
      static AndroidChannelBuilder usingBuilder(ManagedChannelBuilder<out Object> builder) Creates a new builder, which delegates to the given ManagedChannelBuilder.
      AndroidChannelBuilder context(Context context) Enables automatic monitoring of the device's network state.
      ManagedChannel build() Builds a channel with current configurations.
      • Methods inherited from class io.grpc.ForwardingChannelBuilder

        build, compressorRegistry, decompressorRegistry, defaultLoadBalancingPolicy, defaultServiceConfig, directExecutor, disableRetry, disableServiceConfigLookUp, enableFullStreamDecompression, enableRetry, executor, forAddress, forTarget, idleTimeout, intercept, keepAliveTime, keepAliveTimeout, keepAliveWithoutCalls, maxHedgedAttempts, maxInboundMessageSize, maxInboundMetadataSize, maxRetryAttempts, maxTraceEvents, nameResolverFactory, offloadExecutor, overrideAuthority, perRpcBufferLimit, proxyDetector, retryBufferSize, setBinaryLog, toString, usePlaintext, useTransportSecurity, userAgent
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • fromBuilder

        @ExperimentalApi(value = https://github.com/grpc/grpc-java/issues/6043)@Deprecated()@InlineMe(replacement = AndroidChannelBuilder.usingBuilder(builder), imports = io.grpc.android.AndroidChannelBuilder) static AndroidChannelBuilder fromBuilder(ManagedChannelBuilder<out Object> builder)

        Creates a new builder, which delegates to the given ManagedChannelBuilder.

      • usingBuilder

         static AndroidChannelBuilder usingBuilder(ManagedChannelBuilder<out Object> builder)

        Creates a new builder, which delegates to the given ManagedChannelBuilder.

        The provided {@code builder} becomes "owned" by AndroidChannelBuilder. The caller shouldnot modify the provided builder and AndroidChannelBuilder may modify it. That implies reusingthe provided builder to build another channel may result with unexpected configurations. Thatusage should be discouraged.

      • build

         ManagedChannel build()

        Builds a channel with current configurations.