Android integration

Overview

Amend is a Platform–as-a-Service (PaaS) solution hosted on cloud. Amend helps you manage your application’s image resources in the cloud without having to worry about scale and performance. The resources are delivered by high-performance servers through Content Delivery Network (CDN)

Resources are uploaded, managed, and transformed using amend’s easy to use APIs and SDKs. Infrastructure used for these operations is infinitely scalable for handling high load and bursts of traffic.

Quick example

Take a look at the following Amend URL that generates the image below:

baby fit face
150x150 PNG

By calling the above URL Amend is being instructed to transform the uploaded image and create a 150x150px thumbnail using face detection based cropping, round the image's corners, rotate the image by 20 degrees and then deliver resulting image through CDN.

android Library Features

Amend provides an open source Android library for further simplifying the integration:

  • Build URLs for image transformation & manipulation.
  • Android view helper methods for embedding and transforming images.
  • API wrappers: image upload.

Android - Getting started guide

1. Installation

Amend's android integration library is available as an open-source android code. You can download the latest sources from the following link:

http://amendcloud.com/library/android.zip

Import library folder as a module in your android project

Add it as a dependencies on build.gradle file of your main module

compile project(':lib-amend')

import com.tactlab.cloudamend.Amend package in your code:

import com.tactlab.cloudamend.Amend;

2. Configuration

Your amend_name account parameter is required to build image URLs. access_key and access_secret are further needed to perform secure API calls to Amend (e.g. image uploads). See API, URLs and access identifiers for more details.

Setting the configuration parameters can be done the setAmendName and setCredentials method.

You can find your configuration parameters in the dashboard of our Developer Console.

Here's an example of setting configuration parameters globally in your android application:

Amend.setAmendName("your-amendName");
Amend.setCredentials("your-amendKey", "your-amendSecret");

3. Upload images

You can upload images from your android server. Uploading is done over HTTP or HTTPS using a secure protocol based on the access_key and access_secret parameters you provide.

The following command uploads a local file to Amend:

Amend.with(this).upload(reqCode, file, new AmendListener() {
    @Override
    public void onSuccess(int statusCode, int reqCode, AmendResponse response) {
    }
    @Override
    public void onError(int statusCode, int reqCode, Exception e) {
    }
});

Each image uploaded to Amend is assigned a unique Image Name and is available for immediate delivery and transformation. The upload method returns an associative array with content similar to that shown in the following example:

(
    ImageName = "baby"
    Width = 450
    Height = 203
    Size = 2100   
    MimeType = "image/jpg"
    Resolution = 300
    CreatedDate = "2016-09-10T13:25:11Z"
    CDNUrl = http://amend.cloud/test/image/baby
    SecureCDNUrl = https://amend.cloud/test/image/baby
)

4. Display and manipulate images

Adding images to your android imageview is quite straightforward. Just use the load helper method. This method generates the full image resource URL based on the given parameters and internally download and set image on given imageView:

For example, displaying the uploaded image with the baby Image Name, while providing an alternate text:

Amend.with(context).load('baby', new AmendOptions().transform(new Transform().width(250).height(168))).into(img);
amend sample
255x168 JPG

Consider a case where you wish to display a small thumbnail of the uploaded image. Simply add the transformation instructions to your call. For example, displaying the 'sample' image transformed to fill a 100x150 rectangle:

Amend.with(context).load('baby', new AmendOptions().transform(new Transform().width(100).height(150).fit(Amend.FIT_FILL))).into(img);
amend sample
100x150 JPG

Using simple parameters you can perform powerful image manipulations. The android library builds Amend URLs that you can embed in your web and mobile views for dynamically transforming your uploaded images in the cloud and delivering the results through a fast CDN with advanced caching.

You can easily convert resize your images, perform face detection based cropping, apply effects and filters, append textual layers or watermarks and more.

For a full list of supported transformations and their usage, refer to Image transformations.

5. Sample projects

To find additional useful code samples and learn how to integrate Amend with your android applications, take a look at our Sample Projects.

Basic android sample: Uploading local images to Amend and generating various transformation URLs, fetch remote image and perform transformations.

6. What's next

Sign upfor a free account if you haven't done so already. Follow the steps above and try Amend out. Finished all steps? That's just an example of what Amend can offer. Here's some additional reading material to help you get the best out of Amend:

Stay tuned for updates, tips and tutorials: Blog, Twitter, Facebook.