This RingCentral Android SDK has been made to make Android development easier for developers who are using RingCentral Platform's suite of APIs. It handles authentication and the token lifecycle, makes API requests, and parses API responses. This documentation will help you get set up and going with some example API calls.
You can install the RingCentral SDK via JCenter or by installing the AAR file locally.
To add this SDK to your project from JCenter, add this line to your Gradle dependencies for your app. Here is the link to the online repository: https://bintray.com/ringcentral/maven/rc_android_sdk/view Add these to your app's Gradle dependencies:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.ringcentral.rcandroidsdk:rc_android_sdk:0.5'
}- Download AAR from the GitHub release page
- Move AAR file into your app module's
libsdirectory - Edit the
app/build.gradlefile to add the following Gradle script:
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
...
compile 'com.ringcentral.library:ringcentral-android-0-7@aar'
}
Add the follow permissions to your app module's AndroidManifest.xml (app/src/main/AndroidManifest.xml) within the <manifest> tag to utilize RingCentral capabilties:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />To import the SDK to your app, e.g. MainActivity, add this line:
import com.ringcentral.rc_android_sdk.rcsdk.*;Create an instance of the global SDK object in your application, and configure it with your unique API key, secret, and server URL.
sdk = new SDK(appKey, appSecret, Platform.Server.PRODUCTION);sdk = new SDK(appKey, appSecret, Platform.Server.SANDBOX);Platform platform = sdk.platform();With the oldPlatform singleton and the SDK configured with the correct server URL and API key, your application can authenticate to access the features of the API.
Authentication is done by calling the oldPlatform.authorize() method with the username, extension(optional), and password. Also, because the login process is asynchronous, you have to call a new Callback() and pass that in as the last parameter. You can handle login success in the overriding of the Callback's onResponse(), such as performing updates to the user interface. To handle login failure, you can add error handling in onFailure().
platform.login("username", "ext", "password", new Callback() {
@Override
public void onFailure(Request request, IOException e) {
//handle exception
}
@Override
public void onResponse(Response response) throws IOException {
try {
if (response.isSuccessful() && platform.loggedIn()) {
//set the current authorized platform instance to the singleton instance
Singleton.getInstance().setPlatform(helpers);
//start activities
Intent optionsIntent = new Intent(ActivityA.this, ActivityB.class);
startActivity(optionsIntent);
}
} catch (Exception e) {
//handle exception
}
}
});####Checking Authentication State
To check in your Application if the user is authenticated, you can call the oldPlatform singleton's isAuthorized() method which will handle refreshing tokens for you, or throw an exception if the refreshed Access Token is invalid.
platform.loggedIn(); //returns boolean https://github.com/vyshakhbabji/ringcentral-android-sdk-demoapp
RINGCENTRAL ringcental-android SDK is available under an MIT-style license. See LICENSE.md for details.
RINGCENTRAL ringcentral-android © by Vyshakh Babji, Andrew Pang