com.samsung.android.penup

Class PenupClient.Builder

  • java.lang.Object
    • com.samsung.android.penup.PenupClient.Builder
  • Enclosing class:
    PenupClient


    public static final class PenupClient.Builder
    extends java.lang.Object
    This class configures and builds a PenupClient instance.
    Example:
     
     // Configures a PenupClient 
     PenupClient.Builder builder = new PenupClient.Builder(this); 
     builder.setClientId(CLIENT_ID); 
     builder.setCallback(new ConnectionCallback() { 
            
            @Override
            public void onConnectionFailed(ResponseResult responseResult) { 
                    // Checks the response result and tries to connect again 
            }
    
            @Override
            public void onConnected() { 
                    // Calls APIs related to the PEN.UP resource 
            } 
     }); 
     
     builder.addScope(Scope.READ_MY_RESOURCES);
     builder.addScope(Scope.READ_RESOURCES);
     builder.addScope(Scope.POST_RESOURCES);
     
     // Creates an instance of PenupClient 
     PenupClient penupClient = builder.build(); 
    
     // Connects to PEN.UP service 
     penupClient.connect();
     
     
    Since:
    PEN.UP 1.0
    • Constructor Detail

      • PenupClient.Builder

        public PenupClient.Builder(Context context)
        Constructs a Builder instance.
        Parameters:
        context - The context of the application
        Throws:
        java.lang.IllegalArgumentException - The context is set to null.
        Since:
        PEN.UP 1.0
    • Method Detail

      • build

        public PenupClient build()
        Constructs a PenupClient instance with the current attributes.
        Returns:
        A PenupClient instance
        Throws:
        java.lang.IllegalStateException - Thrown when either of the following conditions has occurred:
        • The client ID is set to null or empty.
        • The connection callback is set to null.
        • The scope is not added.
        See Also:
        setClientId(String), setCallback(PenupClient.ConnectionCallback), addScope(Scope)
        Since:
        PEN.UP 1.0
      • setCallback

        public PenupClient.Builder setCallback(PenupClient.ConnectionCallback connectionCallback)
        Sets the callback to receive the connection result.
        Parameters:
        connectionCallback - The ConnectionCallback instance for receiving the connection result
        Since:
        PEN.UP 1.0
      • setClientId

        public PenupClient.Builder setClientId(java.lang.String clientId)
        Sets the client ID that has been issued from the PEN.UP service.
        Parameters:
        clientId - The client ID that has been issued from the PEN.UP service
        Since:
        PEN.UP 1.0
      • addScope

        public PenupClient.Builder addScope(Scope scope)
        Adds the scope to use the PEN.UP resources properly.
        Parameters:
        scope - The OAuth 2.0 scope
        Since:
        PEN.UP 1.0