作者:张振琦
Android 系统上实现Udesk即时通讯,除了使用Udesk提供的原生sdk以外还可以嵌入Udesk提供的即时通讯网页插件。Udesk即时通讯网页插件的内容,大家可以参考《Udesk即时通讯(IM)网页插件入门》 的内容。
如果业务需要同时使用网页即时通讯与移动端即时通讯,Android 嵌入desk即时通讯网页插件有一个很大的优点就是,相对于使用移动SDK单独实现移动端即时通讯,嵌入网页插件可以减少一定的维护成本,只需要维护即时通讯网页插件即可。
Udesk即时通讯网页插件除了使用代码还提供了一个专用连接,Android 嵌入Udesk即时通讯网页插件的核心思路就是,使用Android 的 WebView 打开这个专用连接。下面直接演示如果实现。
新建一个Project,选择Empty Activity,名称为UseWebIM,开发语言Java。
删除主页面中默认的Hello World! 文本,添加一个按钮,名为”打开WebIM联系客服“
activity_mian.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/btn_webim"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/webim"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf