A step-by-step guide to embedding Real-Time Communication features into your Android application

This document is designed to help developers get started using the Temasys SDK for Android to add video & voice calling, secure messaging, and more to their android application. Let’s get started!

Step 1: Create an Account on the Temasys Console (Skip to Step 5 if you have already created an account and generated an App key)
    The Temasys Console is where you’ll be able to create an App Profile and get an App Key.Once you create an account, you will receive a verification email.
    Click the link in the verification email, and then log into the Temasys Console to let the fun begin.
Step 2: Create an App Profile
    Once you’ve logged into the Temasys Console, choose Manage Apps.
    Here you will see the Create App form where you can create your App Profile.
    Add your Application’s name, brief description, related website, the category and how many users you expect to be using your app.
    Click Create.
Step 3: Select the Free Billing Option
    You’ll see a Billing screen with a variety of options, but you don’t need to worry about that right now.
    You can select the Free option while you’re creating and testing your app.
    The Free option, lets you test your code with up to 10 concurrent users and generate 3 associated keys at no charge.
    Click Continue to confirm the Free option.
    Once you’re ready to roll-out your app, you will want to come back to this screen and select the option that best fits your needs.
Step 4: Get an App Key
    Now you’re ready to generate up to 3 App keys.
    Every App key for the Web platform will only work on your specified CORS domain name.
    If you want to have different websites or applications on different platforms (such as Android and iOS) access the same realm and therefore the same rooms, you can create multiple keys under the same application – one for each platform. This extends the scope of the realm to other domains or applications.
Step 5: Begin Your Project
    1. Add the Android SDK to your project
    2. Implement Listeners in the class receiving events from the Temasys SDK.Note: A list of listeners available in the current release and the callbacks they provide can be found here. For older versions just replace “latest” in the URL with the SDK version.Always implement LifeCycleListener and RemotePeerListenerIn addition to that, depending on the functionality you wish to achieve add the respective listener
      • For Audio Call : Implement MediaListener
      • For Video Call : Implement MediaListener
      • For File Transfer : Implement FileTransferListener
      • For Data Transfer : Implement DataTransferListener
      • For Messaging : Implement MessageListener
      • For Recording : Implement RecordingListener
      • public class VideoCallFragment extends Fragment implements LifeCycleListener, MediaListener, RemotePeerListener
        {     /**Implementation of callbacks provided the listeners**/   .....   ..... }
    3. Initialize SkylinkConfig to specify the desired functionality from the Temasys SDK
      private SkylinkConfig getSkylinkConfig() {
      SkylinkConfig config = new SkylinkConfig();
      config.setAudioVideoSendConfig(SkylinkConfig.AudioVideoConfig.AUDIO_AND_VIDEO);
      config.setAudioVideoReceiveConfig(SkylinkConfig.AudioVideoConfig.AUDIO_AND_VIDEO);
      config.setHasPeerMessaging(true);
      config.setHasFileTransfer(true);
      config.setHasDataTransfer(true);
      config.setTimeout(60);
      return config;
      }

      There are four configurations available for  AudioVideoConfig

      • SkylinkConfig.AudioVideoConfig.AUDIO_AND_VIDEO
      • SkylinkConfig.AudioVideoConfig.NO_AUDIO_NO_VIDEO
      • SkylinkConfig.AudioVideoConfig.AUDIO_ONLY
      • SkylinkConfig.AudioVideoConfig.VIDEO_ONLY
    4. Initialize SkylinkConnection object. You can initialize the SkylinkConnection object by providing the App key and secret obtained from the Temasys Console and the config object (obtained in step 7). This registers your application key with the Temasys server.
      SkylinkConnection skylinkConnection;
      .....
      .....
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate();
      skylinkConnection = SkylinkConnection.getInstance();
      skylinkConnection.init(getString(R.string.app_key), getSkylinkConfig(),
      this.getActivity().getApplicationContext());
      // register respective listeners
      skylinkConnection.setLifeCycleListener(this);
      skylinkConnection.setMediaListener(this);
      skylinkConnection.setRemotePeerListener(this);
      .........
      .........
      }
    5. Connect to a room using the Temasys SDK
      A room is where two peers can join and have a conversation. This room can be any alpha-numeric value. In the example below, two peers entering the room MyRoom will be able to communicate with one another.
       // you will be connected to the room named "roomName" using a user name or user data object.skylinkConnection.connectToRoom("secret", "roomName", "userName");
      Note: The Temasys SDK also provides a more secure credentials method for connecting to rooms.Click here for information on generating credentials from your application server.The credentials method is recommended for production applications.

    6. Verify connectivity by implementing debug logging in the callbacks of LifeCycleListener
      /***
              * Lifecycle Listener Callbacks -- triggered during events that happen during the SDK's lifecycle
              *//**
              * Triggered when connection is successful
              *
              * @param isSuccess
              * @param message
              */
      @Override
      public void onConnect(boolean isSuccess, String message) {
      if (isSuccess) {
      Toast.makeText(getActivity(), "Connected to room ").show();
      } else {
      Log.d(TAG, "Skylink Connection Failed");
      }
      }
      @Override
      public void onWarning(int errorCode, String message) {
      String log = "Warning is errorCode " + errorCode + ". Message: " + message + ".";
      Log.d(TAG, log);
      }
      @Override
      public void onDisconnect(int errorCode, String message) {
      String log = "";
      if (errorCode == Errors.DISCONNECT_FROM_ROOM) {
      log += "We have successfully disconnected from the room.";
      } else if (errorCode == Errors.DISCONNECT_UNEXPECTED_ERROR) {
      log += "WARNING! We have been unexpectedly disconnected from the room!";
      }
      log += " Server message: " + message;
      Log.d(TAG, log);
      }
      @Override
      public void onReceiveLog(int infoCode, String message) {
      switch (infoCode) {
      case CAM_SWITCH_FRONT:
      case CAM_SWITCH_NON_FRONT:
      case CAM_SWITCH_NO:
      Toast.makeText(getActivity(), message, Toast.LENGTH_SHORT).show();
      break;
      default:
      Log.d(TAG, "Received SDK log: " + message);
      break;
      }
      }

 

We hope you’ve enjoyed getting started with the Temasys SDK for Android! Have fun, share this and let us know if you run into any issues!

ADDITIONAL RESOURCES

To further demonstrate the possibilities and flexibility of the Temasys SDK for Android, please refer to our simple demo application.  

Temasys Developer Console

Getting Started Guide for the Web

Getting Started Guide for iOS

Share:
Facebook
Facebook
LinkedIn
RSS