Awesome
OpenTok Accelerator Sample App for Android
<img src="https://assets.tokbox.com/img/vonage/Vonage_VideoAPI_black.svg" height="48px" alt="Tokbox is now known as Vonage" />This project demonstrates Accelerator Sample App - multiparty, web-based audio, video, and messaging solution for Android Platform. This project utilizes accelerator-core-android.
Under the hood accelerator-core-android utilizes Vonage Video API Android SDK and opentokRTC.
Getting started
Open this project
There are a few ways to open this project.
Android Studio
- Go to
Android Studio
and selectFile > New > From Version control > Git
- Enter
git@github.com:opentok/accelerator-sample-apps-android.git
into URL field
Command-line + Android Studio
- Run
git clone git@github.com:opentok/accelerator-sample-apps-android.git
to clone project - Go to
Android Studio
and selectFile > Open
and navigate to the newly cloned directory
Set app config
Before running the application, we need to configure project specific settings.
Open the dashboard, select specific application and to get the apiKey
, sessionId
and token
.
Open com.opentok.accelerator.sample.AppConfig
file and fill the apiKey
, sessionId
and token
for your Android project.
For production deployment, you must generate the
SessionId
andtoken
using one of the OpenTok Server SDKs (https://tokbox.com/developer/sdks/server/).
Replace maven dependency with accelerator-core-android code
This project is using implementation 'com.opentok.android:opentok-accelerator-core:x.y.z'
dependency to utilize accelerators. This dependency can be
replaced with accelerator-core-android source code to facilicate developement of your application.
Remove dependency
- Modify the root
build.gradle
file and remove the custom repository:
maven {
url "http://tokbox.bintray.com/maven"
}
- Modify the
app/build.gradle
file and remove accelerator dependency:
implementation 'com.opentok.android:opentok-accelerator-core:x.y.z'
Using the repository
- Clone the OpenTok Accelerator Core repo.
- Go to
Android Studio
and selectNew > Module > Import Gradle Project
and navigate to the newly cloned directory.
Exploring the code
This section describes the best practices the sample app code uses to implement the communication features.
For detail about the APIs used to develop this sample, see the OpenTok Android SDK Reference and Android API Reference.
Class design
Class | Description |
---|---|
MainActivity | Implements the UI and media control callbacks. |
OpenTokConfig | Stores the information required to configure the session and authorize the app to make requests to the backend server. |
ActionBarFragment | Manages the toolbar for the local audio and video controls, the start/end call, text-chat, and screen sharing buttons. |
ScreensharingBar | Defines a view to represent the ScreenSharingBar. |
Participant | Represents an item in the data set |
ParticipantAdapter | Custom RecyclerView.Adapter responsible for providing views that represent items in the data set. |
Session and streams management
The OTWrapper
class, included in the accelerator-core-android is the backbone of the communication features for this app.
This class uses the OpenTok API to initiate the client connection to the OpenTok session and manage the audio and video streams.
otWrapper.connect()
val previewConfig = new PreviewConfig.PreviewConfigBuilder().name("myConfig").build()
otWrapper.startPublishingMedia(previewConfig, false)
otWrapper.enableLocalMedia(MediaType.AUDIO, audio)
otWrapper.disconnect()
The BasicListener
and AdvancedListener
interface monitor OTWraper
state changes.
Development and Contributing
Interested in contributing? We :heart: pull requests! See the Contribution guidelines.
Getting Help
We love to hear from you so if you have questions, comments or find a bug in the project, let us know! You can either:
- Open an issue on this repository
- See https://support.tokbox.com/ for support options
- Tweet at us! We're @VonageDev on Twitter
- Or join the Vonage Developer Community Slack
Further Reading
- Check out the Developer Documentation at https://tokbox.com/developer/