Easy HTTP Request
Android Java
A lightweight wrapper for Android's HttpURLConnection.
It simplifies asynchronous networking by handling background tasks, parameter encoding, and callbacks for GET, POST, file uploads, and image downloading.
Integration
This library consists of a single Java class. No Gradle dependencies are required.
Installation
- Download or copy the
HttpRequest.javafile. - Paste it into your Android project's source package (e.g.,
com.example.myapp.utils). - Import the class wherever you need to make network calls.
Permissions
Ensure you have added the internet permission to your AndroidManifest.xml.
GET Request
Performs an asynchronous GET request. Parameters are automatically URL-encoded and appended to the URL.
POST Request
Sends data via POST method. Content-Type is set to application/x-www-form-urlencoded.
.get()].Ensure you handle threading appropriately if calling from the main thread in older Android versions.
Upload File
Uploads a local file to a server using multipart/form-data.
Download Image
Fetches an image from a URL and returns it as an Android Bitmap object.
API Reference
| Static Method | Description |
|---|---|
| GET(url, params, callback) | Performs an async GET request. Params appended to URL. |
| POST(url, params, callback) | Performs a POST request with form-urlencoded body. |
| Upload_File(url, key, path, cb) | Multipart upload of a file from local storage. |
| Download_Image(url, callback) | Downloads an image and returns a Bitmap object. |