> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://uploadcare.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://uploadcare.com/docs/_mcp/server.

# Android API Client

> Android Uploadcare API client for Fast & Reliable File Uploads; File, Group, Project Operations; Video + Document Conversion; File Uploader integration.

Android (Kotlin and Java) integration handles uploads and file operations by
wrapping Uploadcare [Upload API](https://uploadcare.com/docs/api/upload/) and [REST API](https://uploadcare.com/docs/api/rest/).
This comprehensive API client lets you use most of the Uploadcare features from
within your Android app. It also includes a native uploading widget.

[GitHub →](https://github.com/uploadcare/uploadcare-android)

## Features

Concise and easy-to-use library without extra resources and drawables.

Uploading ([Upload API](https://uploadcare.com/docs/api/upload/)):

* Upload files from a file, byte array, URL, URI and cloud sources (up to 5 TB)
* Multipart uploading for large files
* Track, pause and resume multipart uploads
* Bulk file uploading
* Uploading network to speed uploading jobs (like CDN)

File uploading widget:

* Upload files from a local disk, camera, and cloud sources
* Track upload progress and cancel uploads
* Background uploading
* Material design Uploader appearance customization and styles

File management ([REST API](https://uploadcare.com/docs/api/rest/)):

* Get file info and perform various operations (store/delete/copy) with them
* Work with groups of files
* Get info about account project
* Manage webhooks
* Convert documents
* Encode and transform videos
* Paginated resource fetching
* Synchronous and asynchronous operation modes

Image processing ([URL API](https://uploadcare.com/docs/api/url/)):

* CDN path builder
* Compression
* Geometry
* Colors
* Definition
* Image and text overlays
* Rotations
* Recognition
* File info
* Proxy (fetch)

Security:

* Secure authentication
* Secure uploads (signed uploads)
* Secure delivery (signed URLs)

## Installation from Maven Central

The latest stable versions are available at Maven Central.

To include API client and the uploading widget in your Android project, add
these lines to the `build.gradle` file:

```
implementation 'com.uploadcare.android.library:uploadcare-android:4.3.2'
implementation 'com.uploadcare.android.widget:uploadcare-android-widget:4.3.2'
```

> **Note**
>
> **Note:** `uploadcare-android-widget` depends on `uploadcare-android` transitively. If you use the widget and call the REST/Upload API directly, declare both dependencies at the same version.

## Android 14+ and foreground services

The uploading widget performs background uploads through WorkManager. Starting with version 4.3.2, the widget declares the required foreground service type (`dataSync`) and the `FOREGROUND_SERVICE_DATA_SYNC` permission in its own manifest, so apps targeting Android API 34 or higher work without extra setup.

If your app runs its own long-running WorkManager workers with other foreground service types, combine them with `dataSync` in your `AndroidManifest.xml`:

```xml
<service
    android:name="androidx.work.impl.foreground.SystemForegroundService"
    android:foregroundServiceType="dataSync|your_type"
    tools:node="replace" />
```

## Initialization

REST API requires both public and secret keys. If you use Upload API only,
you can specify just "YOUR_PUBLIC_KEY". Get your Public and Secret
[API keys](https://app.uploadcare.com/projects/-/api-keys/).

Kotlin

```kotlin
val uploadcare = UploadcareClient("YOUR_PUBLIC_KEY", "YOUR_SECRET_KEY")
```

Java

```java
UploadcareClient uploadcare = new UploadcareClient("YOUR_PUBLIC_KEY", "YOUR_SECRET_KEY");
```

For uploading widget, place your Uploadcare public/private keys into the `res/values/strings.xml` file:

```xml
<resources>
    <!--Replace with your public/private keys to use UploadcareWidget. Private key is optional, required only if you use REST API features.-->
    <string name="uploadcare_public_key" translatable="false">place_uploadcare_public_key_here</string>
    <string name="uploadcare_private_key" translatable="false">place_uploadcare_private_key_here</string>
</resources>
```

> **Warning**
>
> **Warning:** Do not ship your secret key in a production Android app: it can be extracted from the app binary. The widget only needs the public key. Set the secret key for local testing only, and route REST API operations that require it through your backend in production.

## Using REST API

You can use both synchronous and asynchronous operations.

### Asynchronous file info fetch

Kotlin

```kotlin
uploadcare.getFileAsync(
        context, // Context
        "YOUR_FILE_UUID", // File UUID
        object : UploadcareFileCallback {
            override fun onFailure(e: UploadcareApiException) {
                // Handle errors.
            }

            override fun onSuccess(result: UploadcareFile) {
                // Successfully fetched file.
            }
        })
```

Java

```java
uploadcare.getFileAsync(
        context, // Context
        "YOUR_FILE_UUID", // File UUID
        new UploadcareFileCallback() {
            @Override
            public void onFailure(@NotNull UploadcareApiException e) {
                // Handle errors.
            }

            @Override
            public void onSuccess(@NonNull UploadcareFile result) {
                // Successfully fetched file.
            }
        });
```

### Synchronous file info fetch

Kotlin

```kotlin
val file = uploadcare.getFile("YOUR_FILE_UUID")
```

Java

```java
UploadcareFile file = uploadcare.getFile("YOUR_FILE_UUID");
```

Find out more examples in the [API client documentation for Android](https://github.com/uploadcare/uploadcare-android/blob/master/documentation/LIBRARY.md) at GitHub.

## Using Upload API

You can use both synchronous and asynchronous operations.

### Asynchronous file upload

Kotlin

```kotlin
val context = ...// Context
val fileUri = ...//resource representing file (File/Uri/InputStream/ByteArray/String types are supported).
val uploader = FileUploader(uploadcare, fileUri, context) // Use "MultipleFilesUploader" for multiple files.
    .store(null)
    // Other upload parameters.

uploader.uploadAsync(object : UploadFileCallback {
    override fun onFailure(e: UploadcareApiException) {
        // Handle errors.
    }

    override fun onProgressUpdate(
                        bytesWritten: Long,
                        contentLength: Long,
                        progress: Double) {
        // Upload progress info.
    }

    override fun onSuccess(result: UploadcareFile) {
        // Successfully uploaded file to Uploadcare.
    }
})

// Cancel upload in progress.
uploader.cancel()
```

Java

```java
Context context = ...// Context
Uri fileUri = ...//resource representing file (File/Uri/InputStream/ByteArray/String types are supported).
Uploader uploader = new FileUploader(uploadcare, fileUri, context) // Use "MultipleFilesUploader" for multiple files.
    .store(null);
    // Other upload parameters.

uploader.uploadAsync(new UploadFileCallback() {
    @Override
    public void onFailure(UploadcareApiException e) {
        // Handle errors.
    }

    @Override
    public void onProgressUpdate(
                        long bytesWritten,
                        long contentLength,
                        double progress) {
        // Upload progress info.
    }

    @Override
    public void onSuccess(UploadcareFile file) {
        // Successfully uploaded file to Uploadcare.
    }
});

// Cancel upload in progress.
uploader.cancel();
```

### Synchronous file upload

Kotlin

```kotlin
val context = ...// Context
val fileUri = ...//resource representing file (File/Uri/InputStream/ByteArray/String types are supported).
val uploader = FileUploader(uploadcare, fileUri, context) // Use "MultipleFilesUploader" for multiple files.
    .store(null)
    // Other upload parameters.

try {
    val file = uploader.upload()
    // Successfully uploaded file to Uploadcare.
} catch (e: UploadFailureException) {
    // Handle errors.
}
```

Java

```java
Context context = ...// Context
Uri fileUri = ...//resource representing file (File/Uri/InputStream/ByteArray/String types are supported).
Uploader uploader = new FileUploader(uploadcare, fileUri, context) // Use "MultipleFilesUploader" for multiple files.
    .store(null);
    // Other upload parameters.

try {
    UploadcareFile file = uploader.upload(null);
    // Successfully uploaded file to Uploadcare.
} catch (UploadFailureException e) {
    // Handle errors.
}
```

Find out more examples in the
[API client documentation for Android](https://github.com/uploadcare/uploadcare-android/blob/master/documentation/LIBRARY.md) at GitHub.

## Using uploading widget

You can select and upload file from any available local file, camera, external source, Activity/Fragment.

Kotlin

```kotlin
// Register Activity Result Launcher
val uploadcareLauncher = registerForActivityResult(UploadcareActivityResultContract) { result ->
    result?.let {
        //handle result.
    }
}

// Launch UploadcareWidget
val params = UploadcareWidgetParams() // set parameters for upload
uploadcareLauncher.launch(params)
```

Java

```java
// Register Activity Result Launcher
ActivityResultLauncher<UploadcareWidgetParams> uploadcareLauncher = registerForActivityResult(UploadcareActivityResultContract.INSTANCE, result -> {
    if (result != null) {
        // handle result.
    }
});

// Launch UploadcareWidget
UploadcareWidgetParams params = new UploadcareWidgetParams(); // set parameters for upload
uploadcareLauncher.launch(params);
```

Find out more examples in the [uploading widget documentation for Android](https://github.com/uploadcare/uploadcare-android/blob/master/documentation/WIDGET.md) at GitHub.

## Related guides

* Integration with [Java](/docs/integrations/java/)