Android

The Help Lightning Android SDK is a Java SDK that allows Help Lightning calls to be embedded into your Android application.

Prerequisites

Before you can use the SDK, you must have an API Key which requires a Help Lightning site with an Enterprise Tier.

Installing the SDK

The Latest version of the Android SDK is 3.8.2

The Help Lightning Android SDK is available from Help Lightning’s maven repository. You can install it by updating your build.gradle:

buildscript {
  repositories {
    maven { url 'https://jitpack.io' }
    maven {
      url "https://maven.helplightning.net"
    }
    google()
    mavenCentral()
  }
}

dependencies {
    implementation 'com.vipaar.lime:hlsdk-light:3.8.2'
}

Make sure your set the Target Android SDK to 35 or later.

Make sure you set the Min Android SDK to 24 or later.

Using the SDK

First, you must initialize the SDK by calling the init(context) function and passing it your Application context.

public class SampleApp extends Application {

    public void onCreate() {
        super.onCreate();
        HLClient.getInstance().init(this);
    }
}

Then, you will need to implement the InCallService interface:

import com.vipaar.lime.hlsdk.client.HLCall;
import com.vipaar.lime.hlsdk.client.HLClient;
import com.vipaar.lime.hlsdk.services.InCallService;

public class CallService extends InCallService {

    private static final TAG = "CallService"

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        HLClient.getInstance().setHLClientDelegate(this);
        return super.onStartCommand(intent, flags, startId);
    }

    /**
     * Called when a call has ended.
     *
     * @param call   The call that ended.
     * @param reason The reason the call ended.
     */
    @Override
    public void onCallEnded(HLCall call, String reason) {
        Log.d(TAG, "onCallEnded");
    }
    
    /**
     * Triggered when user taps the screen capture button.
     *
     * @param call  The ongoing call.
     * @param image The captured screen as a Bitmap.
     */
    @Override
    public void onScreenCaptured(HLCall call, Bitmap image) {
        Log.d(TAG, "onScreenCaptured");
    }
    
    /**
     * Called to invite a third participant into an existing call.
     */
    @Override
    public void onInviteThirdParticipant() {
        Log.d(TAG, "onInviteThirdParticipant");
    }

    /**
     * Checks if the "Share Knowledge" feature is enabled.
     *
     * @return true if enabled, false otherwise.
     */
    @Override
    public boolean isShareKnowledgeEnabled() {
        return false;
    }

    /**
     * Called when user taps "knowledge" in the share menu.
     * <p>
     * Share Knowledge is a way for users to share internal content
     * that might be stored in your app or in a cloud storage
     * that the user has access to through your app. If this does
     * not exist, you can reroute the user to the OS image picker
     * or just return false in {@link HLClientDelegate#isShareKnowledgeEnabled()} to hide this
     * feature.
     * <p>
     * Expects {@link HLClientBase#onKnowledgeSelected(Uri, KnowledgeType)}
     * to be called to deliver the file to the call.
     */
    @Override
    public void onShareKnowledge() {
        Log.d(TAG, "onShareKnowledge")
        // You might launch an activity to pick an image.
        // After the image is chosen, in onActivityResult() for example,
        // you can call this method passing in the uri to the
        // selected image.
        HLClient.getInstance().onKnowledgeSelected(uri, KnowledgeType.IMAGE)
    }

    /**
     * Checks if the "Share Quick Knowledge" feature is enabled.
     *
     * @return true if enabled, false otherwise.
     */
    @Override
    public boolean isShareQuickKnowledgeEnabled() {
        return false;
    }

    /**
     * Called to select a quick overlay for sharing knowledge.
     * <p>
     * Similar to sharing knowledge, sharing quick knowledge for overlay
     * is a way for users to share internal content
     * that might be stored in your app or in a cloud storage
     * that the user has access to through your app. If this does
     * not exist, you can reroute the user to the OS image picker
     * or just return false in {@link HLClientDelegate#isShareQuickKnowledgeEnabled()} to hide this
     * feature.
     * <p>
     * An overlay is put on top of the other shared content in your call,
     * so you can view a live video source with a separate floating
     * image on top of that video.
     * <p>
     * Expects {@link HLClientBase#onQuickKnowledgeOverlaySelected(Uri)}
     * to be called to deliver the image to the call.
     */
    @Override
    public void onSelectKnowledgeQuickOverlay() {
        Log.d(TAG, "onSelectKnowledgeQuickOverlay")
        // You might launch an activity to pick an image.
        // After the image is chosen, in onActivityResult() for example,
        // you can call this method passing in the uri to the
        // selected image.
        HLClient.getInstance().onQuickKnowledgeOverlaySelected(uri)
    }    

    /**
     * Mini View - a minimized view for an ongoing call.
     * When enabled, users can reduce the call screen to a smaller size,
     * allowing them to perform other actions within the application.
     */
    @Override
    boolean isMinimizeCallEnabled();
}

Then you need to create an HLCall object. This should have all the necessary tokens and URLs of the server to join. This information is obtained by interacting with the server RESTful API to create a call/session between users. Typically, this is handled by your integration server.

    ...
    HLCall call = new HLCall.Builder()
        .sessionId(sessionId)
        .sessionToken(sessionToken)
        .userToken(userToken)
        .gssUrl(url)
        .helplightningAPIKey(apiKey)
        .localUserDisplayName(displayName)
        .autoEnableCamera(autoEnableCamera)
        .autoEnableMicrophone(autoEnableMic)
        .autoEnableAudioPlusMode(false)
        .startInMiniView(startInMiniview)
        .build()
                             
    HLClient.getInstance().startCall(call, view.getContext(), CallService.class)
        .then(callId -> {
            Log.d(TAG, "call id" + callId);
        }, err -> {
            Log.e(TAG, "Error starting call.", err);
        });
You must pass startCall a reference to your InCallService implementation if you want it to be used.

InCallService

In order to use the screen share feature, you need to add mediaProjection to the foregroundServiceType of your InCallService implementation in AndroidManifest.xml.

        <service
            android:name=".SampleInCallService"
            android:exported="false"
            android:foregroundServiceType="camera|microphone|mediaProjection" />

If you are not implementing your own InCallService, this is not needed.

Full Examples

Help Lightning maintains a working example in Java. Please read through the documentation in the top level of the repository as it is necessary run the sample integration server!

You can find a complete sample in Help Lightning’s sample repository on github.