Getting Started =============== Follow the steps and you should be able to add video chat into your Android app. Here’s an overview of the things you’ll accomplish in this tutorial. 1. Download JumpChat Android SDK 2. Copy jumpchat-sdk.aar into your project 3. Modify your gradle file to include jumpchat-sdk.aar 4. Create the JumpChat client object 5. Add callback functions 6. Join a room Step 1: Download JumpChat Android SDK ------------------------------------- Download the `sdk `_ from the following url. .. code-block:: sh % wget https://dl.jumpch.at/sdk/jumpchat-android-sdk-latest.zip Step 2: Copy jumpchat-sdk.aar into your project ----------------------------------------------- Include the jumpchat-sdk.aar file into your project. Normally, it is placed in the ``libs`` directory. .. code-block:: sh % cp jumpchat-sdk/jumpchat-sdk.aar my-project/libs Step 3: Modify your build.gradle file ------------------------------------- Modify your ``build.gradle`` file to include the jumpchat-sdk.aar file. Add ``libs`` as a local repository. :: repositories { flatDir { dirs 'libs' } } Add the SDK to the list of dependencies. :: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) ... compile 'at.jumpch:jumpchat-sdk:0.1@aar' ... } Step 4: Create the JumpChat client object ----------------------------------------- Import JCClient class, add callback implementation in class definition, and instantiate JCClient. .. code-block:: java import at.jumpch.sdk.JCClient; ... public class MainActivity extends Activity implements JCClient.Callback { private JCClient mJC; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mJC = new JCClient(this, getApplicationContext()); ... } ... } Step 5: Add callback functions ------------------------------ Add the following implementations for ``JCClient.Callback``. .. code-block:: java import java.util.UUID; import java.util.HashMap; import org.json.JSONObject; public class MainActivity extends Activity implements JCClient.Callback { private HashMap view = new HashMap(); ... public void onVideoAdded(String userid, GLSurfaceView video) { mVideos.put(userid, video); // add video LinearLayout linearLayout = (LinearLayout)findViewById(R.id.videos); linearLayout.addView(view); mVideos.put(userid, view); } public void onVideoRemoved(String userid) { GLSurfaceView view = mVideos.remove(userid); if (view != null) { LinearLayout linearLayout = (LinearLayout)findViewById(R.id.videos); linearLayout.removeView(view); } } public void onRoomInfoUpdated() { } public void onUsersUpdated() { } public void onKicked() { } public void onKnocking(String sessid, String msg) { } public void onSocketError(Exception e) { } public void onSetVideoSize(String userid, int width, int height) { } // Data Channel - callbacks public void onDCUpdateName(String userid, String name) { } public void onDCUpdateAvatar(String userid, Bitmap avatar) { } public void onDCTextMessage(String userid, String msg) { } public void onDCBroadcastState(String useridonDCJoined, Boolean video, Boolean audio) { } public void onDCJoined(String userid) { } public void onDCDataMessage(String userid, JSONObject msg) { } // This can be any string. public String getUserId() { return UUID.randomUUID().toString(); } // This is the name that will be sent to the other people in the room public String getName() { return "android-sdk-example"; } // The bitmap of the avatar public Bitmap getAvatar() { return null; } // base64 encoded avatar string public String getEncodedAvatar() { return ""; } // return custom video capturer public String getVideoCaptureClass() { return ""; } ... } Step 6: Join a room ------------------------------ Join a room. ``Random`` & ``custom`` rooms are currently supported. Random rooms must be 10 characters long. Custom rooms must be registered on the JumpChat website. .. code-block:: java import at.jumpch.sdk.JCClient; public class MainActivity extends Activity implements JCClient.Callback { private JCClient mJC; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mJC = new JCClient(this, getApplicationContext()); mJC.joinRoom("aaaaaaaaaa", "random"); } }