DEV Community

Cover image for How to Build a Clubhouse Clone App with Android and ZEGOCLOUD - A Social Audio App Development
DavidRelo for ZEGOCLOUD

Posted on • Edited on • Originally published at zegocloud.com

How to Build a Clubhouse Clone App with Android and ZEGOCLOUD - A Social Audio App Development

Because of a conversation with Musk, ClubHouse caught fire worldwide and reached a staggering 9.6 million monthly downloads.

Faced with a new social model, how to quickly clone Clubhouse's social gameplay. Enrich the interaction form of your own application.

Today we will introduce how to use ZEGOCLOUD's ZEGOLiveAudioRoom SDK to quickly build a Social Audio App in 10 minutes.

Demo

Prerequisites

Understand the process

The following diagram shows the basic process of creating a live audio room and taking speaker seats to speak:

process

Integrate the zegoliveaudioroom SDK

To integrate the SDK, do the following:

  1. Download the Sample codes, copy the zegoliveaudioroom module to your project (if you have no project, create a new one).
  2. Add the following code to the settings.gradle file:

    include ':zegoliveaudioroom'
    
  3. Modify the build.gradle file of your application, add the following code to the dependencies node:

    implementation project(':zegoliveaudioroom')
    

build.gradle

  1. Modify the build.gradle file of your project, add the following code to the repositories node:

    maven { url 'https://www.jitpack.io' }
    

repositories

  1. Click sync now.

Add permissions

Permissions can be set as needed.

Open the file app/src/main/AndroidManifest.xml, and add the following code:

Note: For Android 6.0 or later, some important permissions must be requested at runtime rather than declared statically in the file AndroidMainfest.xml, therefore, you need to add the following code to do so (requestPermissions is a method of an Android Activity).

Prevent class name obfuscation

To prevent the ZEGOCLOUD SDK public class names from being obfuscated, you can add the following code in the file proguard-rules.pro.

-keep class **.zego.**{*;}
Enter fullscreen mode Exit fullscreen mode

Initialize the zegoliveaudioroom SDK

To initialize the zegoliveaudioroom SDK, get the ZegoRoomManager instance, pass the AppIDof your project.

To receive event callbacks, call the setListener to listen for and handle various events as needed.

Log in

To access the signaling service of Live Audio Room with the zegoliveaudioroom SDK, you must log in first.

Create/Join a live audio room

  • You become a Host after creating a live audio room, and you owe more permissions, such as closing untaken speaker seats, removing a specified listener from the speaker seat, etc.
  • You become a Listener after joining a live audio room, you can take a speaker seat to be a speaker or leave the speaker seat to become a listener again.

To create a live audio room, call the createRoom method:

To join a live audio room, call the joinRoom method:

Send/Receive messages in the room

In a live audio room, both Host and Listeners can send and receive messages.

To send messages, call the sendTextMessage method with message content.

To receive messages, listen for the ZegoMessageServiceListener callback.

Take a speaker seat

To take a speaker seat to speak, call the takeSeat method. And the SDK publishes streams simultaneously.

When there is a new listener takes a seat and becomes a speaker, all participants in the room receive notifications through the ZegoSpeakerSeatServiceListener callback. You can set up a UI refresh action for this callback as needed.


Sign up with ZEGOCLOUD, get 10,000 minutes free every month.

Did you know? 👏

Like and Follow is the biggest encouragement to me
Follow me to learn more technical knowledge
Thank you for reading :)

Learn more

This is one of the live technical articles. Welcome to other articles:

Top comments (0)