Building an Android Video Chat App with In-Call Statistics

Building an Android Video Chat App with In-Call Statistics

When painting, a person needs to be very careful about the brush they choose, the type of canvas, and the paints. A painter only gets this through experience and by trying various methods. Similarly, when building a video calling or video streaming application, you have to consider tons of metrics in order to deliver the best user experience.

In this tutorial, we will look at how we can check the in-call statistics during the Agora video call. We’ll look at how to access and display these statistics for local video, remote video, and other important call aspects, like bandwidth and CPU usage. If you are new to the Agora Android SDK, you can have a look at this quickstart guide to understand how video calling works.


Project Overview

In this project, we will be going over four major statistics callbacks:

  • onRtcStats
  • onNetworkQuality
  • onLocalVideoStats
  • onRemoteVideoStats

All these callbacks are automatically triggered at an interval of 2 seconds so that you have an accurate recording of your data. All these callbacks can be found here.

Using In-Call Stats

We can access the in-call statistics by listening for the onRtcStats, onNetworkQuality, onLocalVideoStats, and onRemoteVideoStats events. These event listeners are part of the Agora IRtcEventEngineHandler class.

Displaying the Stats

Here, we will be using a TextView to display these stats on the front end. For this, we have created an updateTextView function that displays the stats as returned from the above-used callbacks.

Now that we have got all the logic in place, let’s go over each call statistic method and display the relevant stats.

onRtcStats is used to report the statistics of RtcEngine. As soon as the object of RtcEngine is initialized, this callback is triggered. This callback returns a class of type RtcStats, which contains parameters like total duration, users, last-mile delay, CPU usage, memory usage, etc. You can find all the methods here.

To display these parameters you can call theupdateTextView function inside the onRtcStats callback like this:

The onNetworkQuality callback returns the UID, the uplink transmission quality of the user, and the downlink network quality rating of the user. The callback will look something like this:

onLocalVideoStats is used to display all the statistics of a local user video. It returns a class of type LocalVideoStats that includes various parameters like sent bitrate, target bitrate, codec type, capture frame rate, etc. You can have a look at other methods here.

onRemoteVideoStats is used to display all the statistics of a remote user’s video. This callback is executed individually for every user. It returns a class of type RemoteVideoStats that includes various parameters like the UID, delay, width, height, received bitrate, frozen time, etc. You can have a look at other methods here.


Congratulations! You are ready to make your video calling application and perfect it by understanding the in-call statistics from the Agora Android SDK.

You can get the complete code for this application here.

Other Resources

For more information about Agora applications, take a look at the Agora Video Call Quickstart Guide and Agora API Reference.

And take a look at the complete documentation for the functions discussed above and many more here.

I also invite you to join the Agora Developer Slack community.