生活随笔
收集整理的這篇文章主要介紹了
容联云通讯的学习笔记一
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
容聯(lián)云通訊demo下載
1、登陸類LoginActivity,一個(gè)界面,沒有太多解釋
2、初始化及登陸
? 在程序入口初始化SDK并設(shè)置代理—初始化應(yīng)該在程序完全啟動(dòng)(Android Application 創(chuàng)建完成)之后才能調(diào)用。
初始化及登錄建議在一個(gè)函數(shù)體中處理,這樣比較簡(jiǎn)單。在初始化及登錄的過程中要做三件事:
(1)初始化sdk
(2)設(shè)置”通知回調(diào)”的監(jiān)聽
(3)登錄
具體代碼如下:(參考Demo中的SDKCoreHelper.java)
特別提醒:在初始化SDK的步驟中,第二步(設(shè)置注冊(cè)參數(shù)、設(shè)置通知回調(diào)監(jiān)聽)和第三步(驗(yàn)證參數(shù)是否正確,注冊(cè))需要在第一步(初始化SDK的初始化成功的方法onInitialized中實(shí)現(xiàn))
第一步:初始化SDK
if(!ECDevice.isInitialized()) {ECDevice.initial(Context,
new ECDevice.InitListener() {@Override
public void onInitialized() {}@Override
public void onError(Exception exception) {}});
}第二步:設(shè)置注冊(cè)參數(shù)、設(shè)置通知回調(diào)監(jiān)聽ECInitParams
params = ECInitParams.createParams();
params.setUserid(
"用戶開發(fā)的app的登錄賬號(hào)");
params.setAppKey(
"應(yīng)用ID");
params.setToken(
"應(yīng)用Token");
params.setAuthType(ECInitParams.LoginAuthType.NORMAL_AUTH);
params.setMode(ECInitParams.LoginMode.FORCE_LOGIN);
params.setUserid(
"voip賬號(hào)");
params.setPwd(
"voip密碼");
params.setAppKey(
"應(yīng)用ID");
params.setToken(
"應(yīng)用Token");
params.setAuthType(ECInitParams.LoginAuthType.PASSWORD_AUTH);
params.setMode(ECInitParams.LoginMode.FORCE_LOGIN);
params.setOnDeviceConnectListener(
new ECDevice.OnECDeviceConnectListener() {
public void onConnect() {}@Override
public void onDisconnect(ECError error) {}@Override
public void onConnectState(ECDevice.ECConnectState state, ECError error) {
if(state == ECDevice.ECConnectState.CONNECT_FAILED ){
if(error.errorCode == SdkErrorCode.SDK_KICKED_OFF) {}
else{}
return ;}
else if(state == ECDevice.ECConnectState.CONNECT_SUCCESS) {}}});
params.setOnChatReceiveListener(
new OnChatReceiveListener() {@Override
public void OnReceivedMessage(ECMessage msg) {}@Override
public void OnReceiveGroupNoticeMessage(ECGroupNoticeMessage notice) {}@Override
public void onOfflineMessageCount(
int count) {}@Override
public void onReceiveOfflineMessage(List msgs) {}@Override
public void onReceiveOfflineMessageCompletion() {}@Override
public void onServicePersonVersion(
int version) {}});ECVoIPCallManager callInterface = ECDevice.getECVoIPCallManager();
if(callInterface !=
null) {callInterface.setOnVoIPCallListener(
new ECVoIPCallManager.OnVoIPListener() {@Override
public void onCallEvents(ECVoIPCallManager.VoIPCall voipCall) {
if(voipCall ==
null) {Log.e(
"SDKCoreHelper",
"handle call event error , voipCall null");
return ;}ECVoIPCallManager.ECCallState callState = voipCall.callState;
switch (callState) {
case ECCALL_PROCEEDING:
break;
case ECCALL_ALERTING:
break;
case ECCALL_ANSWERED:
break;
case ECCALL_FAILED:
break;
case ECCALL_RELEASED:
break;
default:Log.e(
"SDKCoreHelper",
"handle call event error , callState " + callState);
break;}}});}
if(ECDevice.getECMeetingManager() !=
null) {ECDevice.getECMeetingManager().setOnMeetingListener(
new OnMeetingListener() {@Override
public void onReceiveInterPhoneMeetingMsg(ECInterPhoneMeetingMsg msg) {}@Override
public void onReceiveVoiceMeetingMsg(ECVoiceMeetingMsg msg) {}@Override
public void onReceiveVideoMeetingMsg(ECVideoMeetingMsg msg) {}});}第三步:驗(yàn)證參數(shù)是否正確,注冊(cè)SDK
if(
params.validate()) {ECDevice.login(
params);}
3、LauncherActivity類:主界面類,更改內(nèi)容,已達(dá)到自己所需的功能
這幾天事太多,需要安靜的休息兩天,繼續(xù)努力
總結(jié)
以上是生活随笔為你收集整理的容联云通讯的学习笔记一的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。