URLRequest

Asynchronous HttpURLConnection engine backed by AsyncTask threads. Returns values to UI contexts via Actions wrappers.

Deprecated Warning

AsyncTask implementation is deprecated in API 30+. It is recommended to migrate to ExecutorService handles or Kotlin coroutine constructs.

Methods

URLRequest build(Runnable completionBlock)

Configures the action block to execute on the main thread after receiving a response.

Object getDefaultActionArg()

Returns the raw server response string or returns an "Error: <message>" formatted error string.

void execute(String URL, String method)

Triggers the network task using the specified parameters (e.g. "GET", "POST").

Usage Example

JAVA
URLRequest request = new URLRequest();
request.build(() -> {
    String response = (String) request.getDefaultActionArg();
    if (!response.startsWith("Error:")) {
        parseServerData(response);
    } else {
        showNetworkError();
    }
});
request.execute("https://api.example.com/v1/config", "GET");