# Toggle Video and Audio in Android App

**URL:** <https://openvidu.discourse.group/t/toggle-video-and-audio-in-android-app/1394>\
**Category:** How to implement?\
**Tags:** v2\
**Created:** [July 7, 2020, 11:29am UTC](https://openvidu.discourse.group/t/toggle-video-and-audio-in-android-app/1394 "2020-07-07T11:29:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arush\_Gupta](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/arush_gupta/32/611_2.png) [@Arush\_Gupta](https://openvidu.discourse.group/u/Arush_Gupta)\
**Post date:** [July 7, 2020, 11:29am UTC](https://openvidu.discourse.group/t/toggle-video-and-audio-in-android-app/1394/1 "2020-07-07T11:29:37Z")

</div>

Hi,  
This is a silly question but I could not find the answer in the docs. ☹

So, I have a android app (clone of openvidu’s GitHub android app) which I have successfully connected to my own server. I wanted to toggle audio and video and recv chat messages in the android app, but I could not find the answer in the docs.

How do we toggle video audio and recv chat in an Android app?  
Thanks

---

<div class="post-metadata">

**Author:** ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)\
**Post date:** [July 7, 2020, 11:46am UTC](https://openvidu.discourse.group/t/toggle-video-and-audio-in-android-app/1394/2 "2020-07-07T11:46:33Z")

</div>

Android sample app is a prototype, is not a proper SDK. For that reason, is not supported neither documented.

You will have to take a look to the source code and find yourself.

Maybe some community member can help you.

Regards

---

<div class="post-metadata">

**Author:** ![mihailj](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/mihailj/32/406_2.png) [@mihailj](https://openvidu.discourse.group/u/mihailj)\
**Post date:** [July 7, 2020, 12:14pm UTC](https://openvidu.discourse.group/t/toggle-video-and-audio-in-android-app/1394/3 "2020-07-07T12:14:14Z")

</div>

Hello Arush,

To receive chat messages is actually quite easy, you need to add the code to intercept the message in the **handleServerEvent** function here:

[https://github.com/OpenVidu/openvidu-tutorials/blob/a569a8598495a475c68ff0452a82ee3a9adb7775/openvidu-android/app/src/main/java/io/openvidu/openvidu\_android/websocket/CustomWebSocket.java#L215](https://github.com/OpenVidu/openvidu-tutorials/blob/a569a8598495a475c68ff0452a82ee3a9adb7775/openvidu-android/app/src/main/java/io/openvidu/openvidu_android/websocket/CustomWebSocket.java#L215)

So basically you need to add another switch case:

```
case JsonConstants.SEND_MESSAGE:
     Log.e(TAG, "Send Message " + json.toString());
break;

```

This constant was declared in _JsonConstants.java_ file like this:

`public static final String SEND_MESSAGE = "sendMessage";`

You will be able to parse the JSON payload which has this format:

```
{
  "method": "sendMessage",
  "params": {
    "data": "test chat",
    "type": "signal:chat",
    "from": "con_FVGC0ckCzr"
  },
  "jsonrpc": "2.0"
}

```

For your other issue with disabling/enabling audio/video I can only suggest you to remove/add the audio/video tracks from/to the media stream. I can’t help you with code as mobile apps development is not my expertise.

Regards,  
Mihail

---

<div class="post-metadata">

**Author:** ![Arush\_Gupta](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/arush_gupta/32/611_2.png) [@Arush\_Gupta](https://openvidu.discourse.group/u/Arush_Gupta)\
**Post date:** [July 11, 2020, 7:47am UTC](https://openvidu.discourse.group/t/toggle-video-and-audio-in-android-app/1394/4 "2020-07-11T07:47:17Z")

</div>

Never mind, I have decided to use ionic 🙂
