This tutorial shows how to implement a PreviewFragment/CallFragment combination inside a template or skeleton Android application.
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.
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.
The following steps show how to piece together the application.
Create a default Android Application Project from the Eclipse wizard.
Create a default Android Application Project from the Eclipse wizard.
Add or modify the following entries within your application’s manifest AndroidManifest.xml file:
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="17" />
<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" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:name="android.hardware.camera.front" />
<uses-feature android:name="android.hardware.camera.back" />
<uses-feature android:name="android.hardware.microphone" />
<uses-feature android:name="android.hardware.audio.low_latency" />
Add import statements for the required components to the top of your MainActivity.java file.
import com.cisco.jabber.guest.JabberGuestCall; import android.net.Uri;
Add the following internal class and member variables to your MainActivity.java class.
public static class MyPreviewFragment extends PreviewFragment {
public void setup() {
getView().findViewById(R.id.jcsdk_call_button).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;
Within your activity_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">
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.createInstance(
this,
JabberGuestCall.createUri("YOUR_SERVER", "YOUR_ADDRESS", null));
getFragmentManager().beginTransaction().add(mFrameContainer.getId(), mPreviewFragment).show(mPreviewFragment).commit();
}
@Override
protected void onPause() {
JabberGuestCall.getInstance().end();
super.onPause();
}
When you launch the application, a call should be made to your specified URI.