会话列表
静态方式加载¶
配置布局文件: Activity 对应的布局文件: conversationlist.xml。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/conversationlist"
android:name="io.rong.imkit.fragment.ConversationListFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Activity 中需在 onCreate 中配置
FragmentManager fragmentManage = getSupportFragmentManager();
ConversationListFragment fragement = (ConversationListFragment) fragmentManage.findFragmentById(R.id.conversationlist);
Uri uri = Uri.parse("rong://" + getApplicationInfo().packageName).buildUpon()
.appendPath("conversationlist")
.appendQueryParameter(Conversation.ConversationType.PRIVATE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.GROUP.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.PUBLIC_SERVICE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.APP_PUBLIC_SERVICE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.SYSTEM.getName(), "true")
.build();
fragement.setUri(uri);
动态方式加载¶
ConversationListFragment mConversationListFragment=new ConversationListFragment();
Uri uri = Uri.parse("rong://" + getApplicationInfo().packageName).buildUpon()
.appendPath("conversationlist")
.appendQueryParameter(Conversation.ConversationType.PRIVATE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.GROUP.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.PUBLIC_SERVICE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.APP_PUBLIC_SERVICE.getName(), "false")
.appendQueryParameter(Conversation.ConversationType.SYSTEM.getName(), "true")
.build();
mConversationListFragment.setUri(uri);
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.relativeLayout_main, mConversationListFragment);
transaction.commit();
配置 intent-filter:
SDK 是通过隐式调用的方式来实现界面跳转的。因此需要在 AndroidManifest.xml 中,会话列表 Activity 下面配置 intent-filter,需要手动修改 android:host 是 App 的 ApplicationId。
<activity
android:name="io.rong.fast.activity.ConversationListActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateHidden|adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="${applicationId}"
android:pathPrefix="/conversationlist"
android:scheme="rong" />
</intent-filter>
</activity>
会话列表¶
会话列表参数说明:
参数 | 类型 | 说明 |
---|---|---|
context | Context | 上下文 |
supportedConversation | Map |
定义会话列表支持显示的会话类型,及对应的会话类型是否聚合显示。 |
示例代码:
/**
* 启动会话列表界面。
*/
RongIM.getInstance().startConversationList(Context , supportedConversation)