如果在集成融云SDK报如下错误
是你的 manifest 少配置了聚合的 Activity
解决方案如下 :
1 在 manifest 中 配置 如下代码
<activity android:name=".activity.ConversationListActivity" android:launchMode="singleTask" 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="io.rong.fast" android:pathPrefix="/conversationlist" android:scheme="rong" /> </intent-filter> </activity>此处注意 host 包名改成自己工程包名
2 做 manifest 聚合的 java 类 参考代码如下
public class ConversationListActivity extends FragmentActivity { private TextView mTitle; private RelativeLayout mBack; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.conversationlist); setActionBarTitle(); isReconnect(); } /** * 设置 actionbar 事件 */ private void setActionBarTitle() { mTitle = (TextView) findViewById(R.id.txt1); mBack = (RelativeLayout) findViewById(R.id.back); mTitle.setText("会话列表"); mBack.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); } /** * 判断消息是否是 push 消息 */ private void isReconnect() { Intent intent = getIntent(); String token = null; if (DemoContext.getInstance() != null) { token = DemoContext.getInstance().getSharedPreferences().getString("DEMO_TOKEN","defult"); } //push或通知过来 if (intent != null && intent.getData() != null && intent.getData().getScheme().equals("rong")) { //通过intent.getData().getQueryParameter("push") 为true,判断是否是push消息 if (intent.getData().getQueryParameter("push") != null && intent.getData().getQueryParameter("push").equals("true")) { reconnect(token); } else { //程序切到后台,收到消息后点击进入,会执行这里 if (RongIM.getInstance() == null || RongIM.getInstance().getRongIMClient() == null) { reconnect(token); } else { enterFragment(); } } } } /** * 加载 会话列表 ConversationListFragment */ private void enterFragment() { ConversationListFragment fragment = (ConversationListFragment) getSupportFragmentManager().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(),"true") .appendQueryParameter(Conversation.ConversationType.DISCUSSION.getName(),"true") .appendQueryParameter(Conversation.ConversationType.SYSTEM.getName(),"true") .build(); fragment.setUri(uri); } /** * 重连 * * @param token */ private void reconnect(String token) { if ("io.rong.fast".equals(App.getCurProcessName(getApplicationContext()))) { RongIM.connect(token,new RongIMClient.ConnectCallback() { @Override public void onTokenIncorrect() { } @Override public void onSuccess(String s) { enterFragment(); } @Override public void onError(RongIMClient.ErrorCode errorCode) { } }); } } }
<?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"> <include layout="@layout/actionbar" /> <fragment android:id="@+id/conversationlist" android:name="io.rong.imkit.fragment.ConversationListFragment" android:layout_width="match_parent" android:layout_height="match_parent" /> </LinearLayout>配置完毕 即可解决 聚合会话列表的报错 原文链接:https://www.f2er.com/javaschema/284499.html