android-chat icon indicating copy to clipboard operation
android-chat copied to clipboard

mClient.connect的时候建议放在子线程,否则有可能会造成卡顿。

Open gnmmdk opened this issue 4 years ago • 0 comments

APP一启动的时候欢迎界面是采用播放视频的方式,而Im初始化,会造成播放视频的卡顿。通过工具排查到是Chatmanager->ServiceConnection serviceConnection = new ServiceConnection()->onServiceConnected-> mClient.connect(userId, token)方法;建议将mClient.connect(userId, token) 放置于子线程。以下是我的处理方式: if (!TextUtils.isEmpty(userId) && !TextUtils.isEmpty(token)) { workHandler.post(()->{ try { mClient.connect(userId, token); } catch (RemoteException e) { e.printStackTrace(); } mainHandler.post(() -> { for (IMServiceStatusListener listener : imServiceStatusListeners) { listener.onServiceConnected(); } }); }); }

gnmmdk avatar May 11 '21 01:05 gnmmdk