这里只是做一个简单的记录
1,登录环信官网https://www.easemob.com/product/im,申请账号并新建应用
2,在官网上选择下载->及时通讯云->AndroidSDK->SDK+demo源码进行sdk的下载,然后将SDK中的easeui作为项目module集成到自己的项目中去
3,然后在Mainfest中配置权限
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
4,接着在Application中进行easeui的SDK初始化操作
EaseUI.getInstance().init(this, null);
5,在用户登录界面进行登录操作
EMClient.getInstance().login(usernameView.getText().toString(), pwdView.getText().toString(), new EMCallBack() {
@Override
public void onSuccess() {
startActivity(new Intent(LoginActivity.this, MainActivity.class));
finish();
}
@Override
public void onProgress(int progress, String status) {
}
@Override
public void onError(int code, String error) {
runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(getApplicationContext(), "login failed", 0).show();
}
});
}
});
6,用户列表使用sdk自带的EaseConversationListFragment进行展示
官方开发文档地址:点击打开链接
demo地址:点击打开链接