File selector integration using Android | Sequencing.com

Real-Time Personalization (+RTP) API Guide

Here we will show how to quickly integrate Sequencing File selector harnesses into your Android based application.

Unless you have specific reason, please refer to "Master plugins" or "Sample applications" section as they provide kit for quick boot-straping mobile applications in all in one package.

 

We have developed a Maven/Gradle component to simplify using component library in your project. If you don't have enough experience with Maven/Gradle, refer to gradle guides

There are several prerequisites in order to complete the integration:

  • you need to have a Sequencing account
  • you need to have an OAuth2 application secret
  • you have valid OAuth2 authentication token 

In order to complete integration follow instructions below.

By following steps below you would get following UI

      

 

Prepare environment

1) Create a new Android Gradle based project (i.e. in Android Studio or Eclipse)

2) File selector module prepared as separate module, but it depends on a SequencingOAuth2Client instance from oAuth module. File selector can execute request to server for files with SequencingOAuth2Client instance only. Thus you need 2 modules to be installed: oAuth module and File Selector module

3) Add gradle dependencies

dependencies {
    compile 'com.sequencing:file-selector:1.0.30'
    compile 'com.sequencing:android-oauth:1.0.22'
}

4) Add Gradle jcenter repository

repositories {
   jcenter()
}

Integrate OAuth2

Implement integration as per these instructions.

 

Prepare file selector

1) Add imports

import com.sequencing.androidoauth.core.OAuth2Parameters;
import com.sequencing.androidoauth.core.ISQAuthCallback;
import com.sequencing.fileselector.core.ISQFileCallback;
import com.sequencing.androidoauth.core.SQUIoAuthHandler;
import com.sequencing.fileselector.core.SQUIFileSelectHandler;
import com.sequencing.oauth.config.AuthenticationParameters;
import com.sequencing.oauth.core.Token;

 

2) Store SequencingOAuth2Client instance so it's accessible for further invocations

3) Implement ISQFileCallback which is a callback using which your code gets aware of which file was selected

/**
 * Callback for handling selected file
 * @param entity selected file entity
 * @param activity activity of file selector
 */
void onFileSelected(FileEntity entity, Activity activity);

4) Create SQUIFileSelectHandler instance that is handling file selection process

5) Register your file selection handler by invoking selectFile method with stored SequencingOAuth2Client and callback. This will also start file selection process.

6) When user selects any file and clics on "Continue" button in UI will be invoked user ISQFileCallback implementation and passed to him FileEntity object and current file selector activity. FileEntity is a Java bean with the structure described here.