当前位置:   article > 正文

android.intent.action.view 融云,Android集成融云单聊

android.intent.action.view 融云,Android集成融云单聊

第一步.

点击此处下载

52e8b105992ac664a485d92b3f443c22.png

第二步

新建自己的Demo,导入IMKit和IMLib两个Module,添加依赖

4d62e7b9c8f8585330a0a52d5e7c023d.png

第三步.

初始化,并在清单文件中进行配置

public class App extends Application {

@Override

public void onCreate() {

super.onCreate();

//初始化

RongIM.init(this);

//token值

String token1 ="sTltJPOv/r0kihB1hmeZvw8qgkkWdAJViRK14/KzM38yWaGUkIg8DC7v5YqATLjy5FEuJAiT0K0+Gn1XxPU3UQ==";

//连接融云

RongIM.connect(token1, new RongIMClient.ConnectCallback() {

@Override

public void onTokenIncorrect() {

}

@Override

public void onSuccess(String s) {

Log.d("app", "onTokenIncorrect: "+s);

}

@Override

public void onError(RongIMClient.ErrorCode errorCode) {

}

});

}

}

第四步

新建ConversationActivity,什么也不用写

它的布局

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical">

android:name="io.rong.imkit.fragment.ConversationFragment"

android:layout_width="match_parent"

android:layout_height="match_parent" />

LinearLayout>

第五步

新建ConversationListActivity,同样什么都不用写

它的布局

android:orientation="vertical" android:layout_width="match_parent"

android:layout_height="match_parent">

android:name="io.rong.imkit.fragment.ConversationListFragment"

android:layout_width="match_parent"

android:layout_height="match_parent" />

LinearLayout>

第六步

在需要调用聊天界面的地方写一行代码

public class MainActivity extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

RongIM.getInstance().startPrivateChat(MainActivity.this, "9527", "标题");

}

});

}

}

最重要的,开始进行配置

在IMLib的AndroidManifest.xml中

data

android:name="RONG_CLOUD_APP_KEY"

android:value="换成自己的APP key" />

在应用的 App Module 的 AndroidManifest.xml 文件中,添加 FileProvider 相关配置,修改 android:authorities 为 “您的应用的包名称.FileProvider”。

android:authorities="您的应用包名.FileProvider"

android:exported="false"

android:grantUriPermissions="true">

android:resource="@xml/rc_file_path" />

provider>

融云 SDK 是通过隐式调用的方式来实现界面跳转的。因此您需要在 AndroidManifest.xml 中,您的会话列表 Activity 下面配置 intent-filter,其中,android:host 是您应用的包名,需要手动修改,其他请保持不变。

android:screenOrientation="portrait"

android:windowSoftInputMode="stateHidden|adjustResize">

android:pathPrefix="/conversationlist"

android:scheme="rong" />

intent-filter>

activity>

android:screenOrientation="portrait"

android:windowSoftInputMode="stateHidden|adjustResize">

android:pathPrefix="/conversation/"

android:scheme="rong" />

intent-filter>

activity>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/235941
推荐阅读
相关标签
  

闽ICP备14008679号