How to leave a meeting or end Zoom SDK service programmatically

Description

For the Zoom Android SDK, custom UI, my custom activity extends the SDK’s MeetingActivity, in the @Override public void onBackPressed(), I want to leave the meeting and stop Zoom SDK service.

Currently I use the onClickLeave();, it will show a leave button in the meeting window, user can leave the meeting after clicking on the leave button. However, is there any way to leave the meeting directly without clicking the leave button?

I tried to just finish my custom activity, the meeting window is gone, though the Zoom SDK service is still running at the background, and I can’t join a new meeting because I didn’t leave the old meeting.

Please help, thanks a lot!

gerger

Which version?
latest SDK version

You call leaveCurrentMeeting. E.g. mMeetingService.leaveCurrentMeeting(end);

Hi @gerger, thanks for the post (and thanks to @egon for helping out!).

The method mentioned in the previous reply is correct. The API reference for this can be found here. Please don’t hesitate to reach back out if you encounter any issues while using this method.

Thanks!

Hi @jon.zoom I tried using the following code for leaving a meeting.

mZoomSDK.getMeetingService().leaveCurrentMeeting(true);

It’s restarting my app. I’m using Android Zoom SDK. I couldn’t find the version number.
Help me here please, so that it won’t restart the app.

Hi @nikhildfoe, thanks for using our SDK.

Sorry to hear you’re running into an issue with this. When you observe it “restarting” your app, that sounds like it is crashing and relaunching. Can you get the stack trace of the crash? Also, at what point are you calling this method?

Thanks!

Thanks for replying @jon.zoom . I don’t think it’s a crash because if it is indeed that, why would it result in a relaunch of the app. And when I commented that particular code, the app didn’t “restart”. So, I figured it has got to do with something related to the leave meeting code.

Is there a meeting setting where we can turn on or off for this sort of behaviour?

Anyway, I’ll once again check the stack trace. Thanks.

BTW, I’m using this code to make the user leave meeting whenever from the host side it’s stopped or whenever the user wants to leave the current meeting.

Hi @nikhildfoe,

There is nothing within the Android SDK where we would intentionally “restart” an app. When an Android app crashes for the first time, the OS usually will re-launch the app immediately. Please let me know once you are able to provide the full stack trace of this crash so that we can investigate. :slightly_smiling_face:

Thanks!

Hi @jon.zoom, I looked for the stack trace and I couldn’t find anything related to this or the crash. Can I know if there is any other way to leave meeting other than this method?

Thanks in advance.

Hi @jon.zoom , just found out why it was happening. It seems there’s a call back function onMeetingLeaveComplete() which will be called after successfully leaving a meeting. There was a finish activity code in that callback and then there was another service which will auto-launch our app whenever this particular activity gets destroyed this way.

Anyways, thanks for your help.

I’m glad to hear you were able to figure this out in your app!

Hi @jon.zoom

I have encounter the same issue after called leaveCurrentMeeting(false);

D/sensors_hal( 1307): flushSendCmplt: handle=46
D/sensors_hal_Ctx( 1307): poll:polldata:1, sensor:0, type:0, x:0.000000 y:0.000000 z:12752584845336616345141232632070144.000000
D/sensors_hal_Util( 1307): waitForResponse: timeout=0
E/AndroidRuntime(31614): FATAL EXCEPTION: mqt_native_modules
E/AndroidRuntime(31614): Process: myapp, PID: 31614
E/AndroidRuntime(31614): java.lang.IllegalThreadStateException: onConfNativeMsg is not called from main thread
E/AndroidRuntime(31614): at com.zipow.videobox.s.b.f.a(ZmConfStateMgr.java:69)
E/AndroidRuntime(31614): at com.zipow.videobox.conference.jni.ZmConfDefaultCallback.onConfStatusChanged(ZmConfDefaultCallback.java:1)
E/AndroidRuntime(31614): at us.zoom.internal.jni.helper.ZoomMeetingSDKMeetingHelper.leaveOrEndMeetingImpl(Native Method)
E/AndroidRuntime(31614): at us.zoom.internal.jni.helper.ZoomMeetingSDKMeetingHelper.b(ZoomMeetingSDKMeetingHelper.java:2)
E/AndroidRuntime(31614): at us.zoom.internal.impl.f0.leaveCurrentMeeting(MeetingServiceImpl.java:11)
E/AndroidRuntime(31614): at myapp.MyMainActivity.leaveVideoConsultation(MyMainActivity.java:334)
E/AndroidRuntime(31614): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(31614): at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(31614): at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
E/AndroidRuntime(31614): at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
E/AndroidRuntime(31614): at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
E/AndroidRuntime(31614): at android.os.Handler.handleCallback(Handler.java:739)
E/AndroidRuntime(31614): at android.os.Handler.dispatchMessage(Handler.java:95)
E/AndroidRuntime(31614): at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
E/AndroidRuntime(31614): at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(31614): at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
E/AndroidRuntime(31614): at java.lang.Thread.run(Thread.java:818)
D/LGImageQualityEnhancementService( 5748): activityResuming: myapp/myapp.MyMeetingActivity
D/LGImageQualityEnhancementService( 5748): handleCallbackActivity(), isEnhanced: false

Thanks

Hi @shingshing6,

Based on the error you are seeing, it appears that you are not calling leaveCurrentMeeting from the main thread. Please keep in mind that all SDK methods must be called from the main thread.

Thanks!

Hi @jon.zoom

Yup, but how can i ensure it is called from main thread? Or how to check if i am on the main thread or not?

When i call getMeetingStatus, it can return the current meeting status. Just call leaveCurrentMeeting will cause the error.

thanks

Hi @shingshing6,

Managing threads in your application is outside of the scope of what the SDK is responsible for, so I would recommend checking out the official Android documentation on the topic.

When i call getMeetingStatus, it can return the current meeting status. Just call leaveCurrentMeeting will cause the error.

Not all SDK methods will cause a crash when called outside of the main thread, but all of them should be called on the main thread.

Thanks!