Introduction
Jabber Guest for Android includes a selection of sample tutorials for getting comfortable with the technology quickly and easily.
Basic Call
Overview
This tutorial shows how to implement a RemoteView inside a template or skeleton Android application.
Requirements
This tutorial requires either that you use the public sandbox or have your own private sandbox or internal Jabber Guest server environment. This document also assumes the reader is comfortable with Java for Android.
Purpose
This is a very quick tutorial on how quickly you can set up a new project to incorporate Jabber Guest video technology. It intentionally eschews safety and error checking for speed so view it only as an example of the general steps to take to get Jabber Guest integrated into your application.
Steps
The following steps show how to piece together the application.
- Create an Android Application
Create a default Android Application Project from the Eclipse wizard.
- Download and Include the library
Create a default Android Application Project from the Eclipse wizard. - Update the Manifest
Add or modify the entries in the right hand panel within your application’s manifest AndroidManifest.xml file:
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
<uses-permission android:name="android.permission.BLUETOOTH">
<uses-permission android:name="android.permission.CAMERA" >
<uses-permission android:name="android.permission.INTERNET" >
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" >
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
<uses-permission android:name="android.permission.RECORD_AUDIO" >
<uses-feature android:name="android.hardware.camera" android:required="false" >
<uses-feature android:name="android.hardware.camera.any" >
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" >
<uses-feature android:name="android.hardware.microphone" >
<uses-feature android:name="android.hardware.bluetooth" android:required="false" >
<uses-feature android:name="android.hardware.audio.low_latency" android:required="false" >
<uses-feature android:name="android.hardware.screen.portrait" android:required="false" >
- Add the RemoteView to the Activity layout
Within youractivity_main.xml
file, add the RemoteView to the layout.
<com.cisco.jabber.guest.RemoteView
android:id="@+id/remoteView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</com.cisco.jabber.guest.RemoteView>
- Create and use the JabberCall instance
Add import statements for the required components to the top of yourMainActivity.java
file.
import com.cisco.jabber.guest.JabberGuestCall;
import com.cisco.jabber.guest.JabberGuestCall.JabberGuestInvalidCertificateCallback;
Add onPause() and replace onCreate with the following code to your MainActivity.java
class. You will need to specify your own URI target in the JabberCall.createInstance() method.
We also add the invalid certificate handler in case your Jabber Guest server is not using a properly-signed certificate.
// Class to handle invalid certificate notifications
class JabberGuestCertificateHandler implements JabberGuestInvalidCertificateCallback {
@Override
public void onInvalidCertificate(String certFingerprint,
String identifierToDisplay,
String certSubjectCN, String referenceID,
List<String> invalidReason, String subjectCertificateData,
List<String> intermediateCACertificateData,
boolean allowUserToAccept) {
// For this sample we are accepting all certificates
JabberGuestCall.getInstance().acceptInvalidCertificate(referenceID, subjectCertificateData);
}
}
JabberGuestCertificateHandler mCertificateHandler = new JabberGuestCertificateHandler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
JabberGuestCall instance = JabberGuestCall.createInstance(
this,
JabberGuestCall.createUri("YOUR_SERVER", "YOUR_ADDRESS", null));
JabberGuestCall.registerInvalidCertificateHandler(mCertificateHandler);
instance.registerContext(this);
instance.start();
}
@Override
protected void onPause() {
JabberGuestCall.unregisterInvalidCertificateHandler(mCertificateHandler);
JabberGuestCall.getInstance().end();
super.onPause();
}
- Run the Application
When you launch the application, a call should be made to your specified URI.
Basic Preview
Overview
This tutorial shows how to implement a PreviewFragment/CallFragment combination inside a template or skeleton Android application.
Requirements
This tutorial requires either that you use the public sandbox or have your own private sandbox or internal Jabber Guest server environment. This document also assumes the reader is comfortable with Java for Android.
Purpose
This is a very quick tutorial on how quickly you can set up a new project to incorporate Jabber Guest video technology. It intentionally eschews safety and error checking for speed so view it only as an example of the general steps to take to get Jabber Guest integrated into your application.
Steps
The following steps show how to piece together the application.
Create an Android Application
Create a default Android Application Project from the Eclipse wizard.
Download and Include the library
Create a default Android Application Project from the Eclipse wizard.
Update the Manifest
Add or modify the following entries within your application’s manifest AndroidManifest.xml file:
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="21" >
<uses-feature
android:glEsVersion="0x00020000"
android:required="true">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE">
<uses-permission android:name="android.permission.BLUETOOTH">
<uses-permission android:name="android.permission.CAMERA" >
<uses-permission android:name="android.permission.INTERNET" >
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" >
<uses-permission android:name="android.permission.READ_PHONE_STATE" >
<uses-permission android:name="android.permission.RECORD_AUDIO" >
<uses-feature android:name="android.hardware.camera" android:required="false" >
<uses-feature android:name="android.hardware.camera.any" >
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" >
<uses-feature android:name="android.hardware.microphone" >
<uses-feature android:name="android.hardware.bluetooth" android:required="false" >
<uses-feature android:name="android.hardware.audio.low_latency" android:required="false" >
<uses-feature android:name="android.hardware.screen.portrait" android:required="false" >
- Add the CallFragment and PreviewFragment to the Activity
Add import statements for the required components to the top of yourMainActivity.java
file.
import com.cisco.jabber.guest.CallFragment;
import com.cisco.jabber.guest.JabberGuestCall;
import com.cisco.jabber.guest.PreviewFragment;
import com.cisco.jabber.guest.JabberGuestCall.JabberGuestInvalidCertificateCallback;
Add the following internal class and member variables to your MainActivity.java
class.
// Class to handle invalid certificate notifications
class JabberGuestCertificateHandler implements JabberGuestInvalidCertificateCallback {
@Override
public void onInvalidCertificate(String certFingerprint,
String identifierToDisplay,
String certSubjectCN, String referenceID,
List<String> invalidReason, String subjectCertificateData,
List<String> intermediateCACertificateData,
boolean allowUserToAccept) {
// For this sample we are accepting all certificates
JabberGuestCall.getInstance().acceptInvalidCertificate(referenceID, subjectCertificateData);
}
}
JabberGuestCertificateHandler mCertificateHandler = new JabberGuestCertificateHandler();
public static class MyPreviewFragment extends PreviewFragment {
public void setup() {
Button btn = (Button)getView().findViewById(R.id.jgsdk_call_button);
btn.setOnClickListener(
new OnClickListener() {
@Override
public void onClick(View v) {
getFragmentManager()
.beginTransaction()
.add(getId(), mCallFragment)
.show(mCallFragment)
.commit();
}
});
}
};
private static FrameLayout mFrameContainer;
private static CallFragment mCallFragment;
private static MyPreviewFragment mPreviewFragment;
- Add the view Holder for the Fragments
Within youractivity_main.xml
file, add the FrameLayout to the layout as a holder for your Fragments.
<FrameLayout
android:id="@+id/frameContainer"
android:background="#000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_margin="40dp">
- Create and use the JabberCall instance
Add onPause() and replace onCreate with the following code to your
MainActivity.java
class. You will need to specify your own server and target in the JabberCall.createInstance() method.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mFrameContainer = (FrameLayout) this.findViewById(R.id.frameContainer);
mCallFragment = new CallFragment();
mPreviewFragment = new MyPreviewFragment();
JabberGuestCall instance = JabberGuestCall.createInstance(
this,
JabberGuestCall.createUri("jabberguestsandbox.cisco.com", "5555", null));
JabberGuestCall.registerInvalidCertificateHandler(mCertificateHandler);
instance.registerContext(this);
getFragmentManager()
.beginTransaction()
.add(mFrameContainer.getId(), mPreviewFragment)
.show(mPreviewFragment)
.commit();
}
@Override
protected void onPause() {
JabberGuestCall.unregisterInvalidCertificateHandler(mCertificateHandler);
JabberGuestCall.getInstance().end();
super.onPause();
}
- Run the Application
When you launch the application, a call should be made to your specified URI.
Sample Apps
Overview
The sample apps described below are bundled with the SDK, both to assist with learning and to provide a starting point for some development projects.
CallSample
A basic application showing how integrate Jabber Guest using a fixed call URI.
It makes use of the CallFragment to establish connection between call parties. It also shows how to handle call state changes and invalid certificates.
CustomSample
A custom application showing how use the smallest user interface pieces of the Jabber Guest SDK.
It makes use of SelfView, RemoteView and CallBarView. It also shows how to handle call state changes and invalid certificates.
InterviewSample
A sample application showing how the Jabber Guest SDK could be used to schedule and incorporate remote interviews.
It makes use of RemoteView, CallBarView and PreviewFragment. It also shows how to handle call state changes and invalid certificates.
LaunchSample
A simple application showing how launch Jabber Guest from your application.
The Jabber Guest client application must be installed on the device.
PreviewSample
A Jabber Guest integrated application showing the flow of the PreviewFragment.
It makes use of CallFragment and PreviewFragment. It also shows how to handle call state changes and invalid certificates.
RemoteShareSample
A custom sample app showing how to use the DataView to receive remote share video stream.
It also show how to handle call control events, call error events and state changes.