获取会话类型 (IMKit 4.x/5.x)

IMKit 4.x, 隐式跳转:

startConversation 开启会话将通过隐式 intent 打开相应 Activity ,并传递相应数据,如会话类型、会话 ID、会话标题等。如果想在会话 Activity 的 onCreate 一开始就获取的话,可以通过以下方式:

Uri uri = getIntent().getData();
String typeStr = uri.getLastPathSegment().toUpperCase(Locale.US);
Conversation.ConversationType conversationType = Conversation.ConversationType.valueOf(typeStr);

如果会话 Activity 的 ConversationFragment 已经显示在界面,可以使用此 Fragment 的 getConversationType 方法。

IMKit 5.x, 显式跳转:

IMKit 5.x把之前的隐式跳转方式改为了显式跳转, 直接从intent取值即可

getIntent().getStringExtra(RouteUtils.CONVERSATION_TYPE);