当前知识库站点已不再维护。请移步新版知识库:https://help.rongcloud.cn/

进入会话页面默认显示语音输入 (IMKit 4.x/5.x)

可以设置输入框的模式,融云目前提供了 5 种排列组合模式,但无法在进入会话页面时默认显示语音输入,怎么实现这个需求?
发布时间: 2018-05-04 15:07

回答:

IMKit 4.x:

可以在集成ConversationFragment的Activity的onResume方法中添加点击语音开关的逻辑,如下:

@Override
protected void onResume() {
    super.onResume();
    clickVoiceToggle();
}

private void clickVoiceToggle() {
    if (initStatus) {
        voiceToggle = findViewById(R.id.rc_voice_toggle);
        voiceToggle.performClick();
        
        initStatus = false;
    }
}

initStatus初始化时为true


IMKit 5.x:

也是继承ConversationFragment, 然后在onResume里写这个逻辑:

@Override
public void onResume() {
    super.onResume();
    mRongExtension.updateInputMode(InputMode.VoiceInput);
}