# Thread issue for chat? v5.9+ and before too?

**URL:** <https://devforum.zoom.us/t/thread-issue-for-chat-v5-9-and-before-too/66129>\
**Category:** Android\
**Created:** [March 20, 2022, 9:16pm UTC](https://devforum.zoom.us/t/thread-issue-for-chat-v5-9-and-before-too/66129 "2022-03-20T21:16:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![larham](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/larham/32/36161_2.png) [@larham](https://devforum.zoom.us/u/larham)\
**Post date:** [March 20, 2022, 9:16pm UTC](https://devforum.zoom.us/t/thread-issue-for-chat-v5-9-and-before-too/66129/1 "2022-03-20T21:16:46Z")

</div>

Although sendChatToGroup() works on a callback thread, it does not seem to work on a “fresh” thread. Similar for direct message.

You can validate this problem using the function attempt2chats() at bottom. A call to the function can be inserted around line 396 of the sample app’s MyMeetingActivity.java, after lines:

```auto
private void refreshToolbar() {
     if (mMeetingService.getMeetingStatus() == MeetingStatus.MEETING_STATUS_INMEETING) {

```

That refreshToolbar() function is called during a _callback_ from OnMeetingStatusChanged(), and as such, the calling thread supports outgoing chat. (If you want the full MyMeetingActivity file to test with, please contact me. Does zoom allow posting of such samples as a ‘gist’ publicly?)

**Version**  
This applies to the Android SDK v5.9+, and probably before too (I recall seeing this behavior several releases ago).

**Steps To Reproduce**

1. Insert attempt2chats() into sdk sample code as mentioned above
2. Launch **different** (normal) client into meeting beforehand, to receive chats and validate.
3. Join meeting with modified sample client
4. Validate that group chat has one message, but not two.
5. Validate there is no error result for 2nd attempt in separate, fresh thread; it is echoed to sending client but not to actual group chat.

**Smartphone:**

- Device: Pixel 1,3
- OS: android 10, 12 respectively

**Additional context**  
Important: validate this with at least 2 attendees in the group chat; message is echoed to local sample client but NOT to others

=============

```auto
import android.content.Context;
import android.util.Log;
import android.widget.Toast;

import us.zoom.sdk.MobileRTCSDKError;
import us.zoom.sdk.ZoomSDK;
import us.zoom.sdk.InMeetingChatController;

/**
 * class which shows that zoom android SDK v5.9x cannot chat from fresh thread.
 * insert call to this around line 396 of MyMeetingActivity.java, which has lines:
 * private void refreshToolbar() {
 * if (mMeetingService.getMeetingStatus() == MeetingStatus.MEETING_STATUS_INMEETING) {
 */

public class TwoChats {
    private static final String TAG = "chatThreadIssue";

    private void attempt2chats(Context context) {
        // hack to test chat from zoom callback vs fresh thread
        Toast.makeText(context, "attempting chat...", Toast.LENGTH_SHORT).show();
        final MobileRTCSDKError result = ZoomSDK.getInstance().getInMeetingService()
                .getInMeetingChatController()
                .sendChatToGroup(
                        InMeetingChatController.MobileRTCChatGroup.MobileRTCChatGroup_All,
                        "test message in callback");

        if (result != MobileRTCSDKError.SDKERR_SUCCESS) {
            Toast.makeText(context, "chat error in callback: " + result, Toast.LENGTH_SHORT).show();
            Log.d(TAG, "got chat err in callback: " + result);
        }

        Runnable freshThread = new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000); // wait for previous chatting to be "not too frequent"
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                final MobileRTCSDKError result = ZoomSDK.getInstance().getInMeetingService()
                        .getInMeetingChatController()
                        .sendChatToGroup(
                                InMeetingChatController.MobileRTCChatGroup.MobileRTCChatGroup_All,
                                "test message in thread");

                if (result != MobileRTCSDKError.SDKERR_SUCCESS) {
                    Log.d(TAG, "got chat err in thread: " + result);
                }
            }
        } ;

        new Thread(freshThread).start();
    }
}

```

---

<div class="post-metadata">

**Author:** ![jon.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jon.zoom/32/13495_2.png) [@jon.zoom](https://devforum.zoom.us/u/jon.zoom)\
**Post date:** [March 21, 2022, 6:57pm UTC](https://devforum.zoom.us/t/thread-issue-for-chat-v5-9-and-before-too/66129/2 "2022-03-21T18:57:39Z")

</div>

Hi @larham, thanks for using the dev forum.

When using the SDK, you must call all methods from the main thread. Usage of the SDK outside of the main thread is not supported. 🙂

Thanks!

---

<div class="post-metadata">

**Author:** ![larham](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/larham/32/36161_2.png) [@larham](https://devforum.zoom.us/u/larham)\
**Post date:** [March 22, 2022, 1:10am UTC](https://devforum.zoom.us/t/thread-issue-for-chat-v5-9-and-before-too/66129/3 "2022-03-22T01:10:04Z")

</div>

Thanks, now that I know what to look for, I found [SDK Initialization](https://marketplace.zoom.us/docs/sdk/native-sdks/android/mastering-zoom-sdk/sdk-initialization/) which states “Main Thread  
Please note that SDK initialization and all API call must run in Main Thread.”

My 2 cents: this feels like a restriction worthy of mentioning elsewhere in docs, perhaps in language not associated with initialization. And removing the restriction even better 🙂

---

<div class="post-metadata">

**Author:** ![jon.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jon.zoom/32/13495_2.png) [@jon.zoom](https://devforum.zoom.us/u/jon.zoom)\
**Post date:** [March 22, 2022, 5:42pm UTC](https://devforum.zoom.us/t/thread-issue-for-chat-v5-9-and-before-too/66129/4 "2022-03-22T17:42:42Z")

</div>

Hi @larham,

Thanks for the feedback! We definitely have some improvements to make in our documentation and will make note of this in particular as we continue working on improving our SDK documentation.

Thanks!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [April 22, 2022, 3:43am UTC](https://devforum.zoom.us/t/thread-issue-for-chat-v5-9-and-before-too/66129/5 "2022-04-22T03:43:40Z")

</div>

Closed on April 22, 2022, 3:43am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
