# Agora Android 1-to-1 Tutorial
This tutorial enables you to quickly get started in your development efforts to create an Android app with real-time video calls, voice calls, and interactive broadcasting. With this sample app you can:
* Join and leave a channel.
* Mute and unmute audio.
* Enable or disable video.
* Choose between the front or rear camera.
A more complete demonstration can be found [here](https://github.com/AgoraIO/OpenVideoCall-Android).
## Prerequisites
* Android Studio 2.0 or above.
* Android device (e.g. Nexus 5X). A real device is recommended because some simulators have missing functionality or lack the performance necessary to run the sample.
## Quick Start
This section shows you how to prepare, build, and run the sample application.
### Create an Account and Obtain an App ID
In order to build and run the sample application you must obtain an App ID:
1. Create a developer account at [agora.io](https://dashboard.agora.io/signin/). Once you finish the signup process, you will be redirected to the Dashboard.
2. Navigate in the Dashboard tree on the left to **Projects** > **Project List**.
3. Locate the file **app/src/main/res/values/strings.xml** and replace <#YOUR APP ID#> with the App ID in the dashboard.
```xml
<string name="agora_app_id"><#YOUR APP ID#></string>
```
### Integrate the Agora Video SDK into the sample project
The SDK must be integrated into the sample project before it can opened and built. There are two methods for integrating the Agora Video SDK into the sample project. The first method uses JCenter to automatically integrate the SDK files. The second method requires you to manually copy the SDK files to the project.
#### Method 1 - Integrate the SDK Automatically Using JCenter (Recommended)
1. Clone this repository.
2. Open **app/build.gradle** and add the following line to the `dependencies` list:
```
...
dependencies {
...
compile 'io.agora.rtc:full-sdk:2.2.3'
}
```
#### Method 2 - Manually copy the SDK files
1. Clone this repository.
2. Download the Agora Video SDK from [Agora.io SDK](https://www.agora.io/en/download/).
3. Unzip the downloaded SDK package.
4. Copy the .jar file from the **libs** folder of the downloaded SDK package to the **/apps/libs** folder of the sample application.
5. Copy the .so files from the **armeabi-v7a** folder of the downloaded SDK package to the **/app/src/main/jniLibs/armeabi-v7a** folder of the sample application.
6. *(Optional)* Copy the .so files from the **arm64-v8a** folder of the downloaded SDK package to the **/app/src/main/jniLibs/arm64-v8a** folder of the sample application.
7. *(Optional)* Copy the .so files from the **x86** folder of the downloaded SDK package to the **/app/src/main/jniLibs/x86** folder of the sample application.
### Obtain and Build the Sample Application
1. Open the sample application in Android Studio.
2. Build and run the sample project. This should display the application on your device.
## Steps to Create the Sample
* [Set Permission](#set-permissions)
* [Create Visual Assets](#create-visual-assets)
* [Design the User Interface](#design-the-user-interface)
For details about the APIs used to develop this sample, see the [Agora.io Documentation version 2.2](https://docs.agora.io/en/2.2).
## Set Permissions
In the `AndroidManifest.xml` file, `uses-permissions` settings were added for the Internet, audio recording, audio settings, network state, camera, and Bluetooth to allow the app to access these features:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.agora.tutorials1v1vcall">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".VideoChatViewActivity"
android:screenOrientation="sensorPortrait"
android:theme="@style/FullScreenVideoTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
```
### Create Visual Assets
Add the following icon assets for the user interface to the */res/drawable* folder:
|Asset |Description |
|------------------------|---------------------------------------------------------------------------------------------------|
|`btn_end_call.png`|An image of a red telephone for a *hang up* button.|
|`btn_mute.png`|An image of a microphone to mute audio.|
|`btn_switch_camera.png`|An image of a camera and rotational arrows to switch between the two cameras.|
|`btn_video.png`|An image of a camera to start video.|
|`btn_voice.png`|An image of an arrow indicating that audio chat is enabled.|
|`ic_launcher.png`|A desktop icon for users to invoke the sample application.|
### Design the User Interface
The sample contains a single activity called *VideoChatViewActivity* and its layout is defined in */layout/activity_video_chat_view.xml*.
The main aspects of this layout are shown here:

|Component |Description |
|---------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
|`activity_video_chat_view` |A view that handles the main video feed. This view contains other views.|
|`remote_video_view_container` |A view displaying the remote, incoming video feed (for example, the video the user will see).|
|`local_video_view_container` |A smaller view at the top right corner showing the local video feed.|
|`quick_tips_when_use_agora_sdk` |Displays quick tip information.|
|`LinearLayout (unamed)` |A layout that encapsulates four buttons: **Pause Video**, **Audio Mute**, **Switch Camera**, and **Hang Up**. Each button uses the assets described above.|
## Configure Resources
To configure 1-to-1 communication resources:
* [Create an Agora Instance](#create-an-agora-instance)
* [Configure the Video Mode](#configure-video-mode)
* [Set up Local Video](#set-up-local-video)
* [Join a Channel](#join-a-channel)
* [Set up Video Chat View Activity](#set-up-video-chat-view-activity)
### Create an Agora Instance
The code samples in this section are in *ViewChatViewActivity.java*.
The following imports define the interface of the Agora API that provides communication functionality:
- `io.agora.rtc.Constants`
- `io.agora.rtc.IRtcEngineEventHandler`
- `io.agora.rtc.RtcEngine`
- `io.agora.rtc.video.VideoCanvas`
Create a singleton by invoking [RtcEngine.create()](https://docs.agora.io/en/2.2/product/Interactive%20Gaming/API%20Reference/game_android?platform=Android) during initialization, passing the application ID stored in *strings.xml* and a reference to the activity's event handler. The Agora API uses events to inform the application about Agora engine runtime events, such as joining or leaving a channel and adding new participants.
```java
import io.agora.rtc.Constants;
import io.agora.rtc.IRtcEngineEventHandler;
import io.ago