跳转至

聚合会话列表

SDK 支持在会话列表页面会话以聚合形式展示。

静态方式加载

配置布局文件: Activity 对应的布局文件:subconversationlist.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <fragment
        android:id="@+id/subconversationlist"
        android:name="io.rong.imkit.fragment.SubConversationListFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</LinearLayout>

Activity 中需在 onCreate 中配置

    public class SubConversationListActivtiy extends FragmentActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.subconversationlist);
        FragmentManager fragmentManage = getSupportFragmentManager();
        SubConversationListFragment fragement = (SubConversationListFragment) fragmentManage.findFragmentById(R.id.conversationlist);
        Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon()
                .appendPath("subconversationlist")
                .appendQueryParameter("type", conversationType.getName())
                .build();
        fragement.setUri(uri);
      }
}
动态方式加载
SubConversationListFragment mSubConversationListFragment=new SubConversationListFragment();
    Uri uri = Uri.parse("rong://" + context.getApplicationInfo().packageName).buildUpon()
                .appendPath("subconversationlist")
                .appendQueryParameter("type", conversationType.getName())
                .build();
    mSubConversationListFragment.setUri(uri);
    FragmentManager manager = getSupportFragmentManager();
    FragmentTransaction transaction = manager.beginTransaction();
    transaction.replace(R.id.relativeLayout_main, mSubConversationListFragment);
    transaction.commit(); 

配置 intent-filter:

SDK 是通过隐式调用的方式来实现界面跳转的。因此需要在 AndroidManifest.xml 中,会话列表 Activity 下面配置 intent-filter,需要手动修改 android:host 是 App 的 ApplicationId。

<!--聚合会话列表-->
 <activity
     android:name="io.rong.fast.activity.SubConversationListActivtiy"
     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="/subconversationlist"
             android:scheme="rong" />
     </intent-filter>
 </activity>
聚合会话列表

聚合会话列表参数说明:

参数 类型 说明
context Context 上下文
ConversationType conversationType 会话类型

示例代码:

/**
 * 启动会话列表界面。
 */
RongIM.getInstance().startSubConversationList(Context , conversationType)