容联云通讯的学习笔记二
生活随笔
收集整理的這篇文章主要介紹了
容联云通讯的学习笔记二
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
先把demo中的功能理清,分析需要哪些功能吧
容聯云通訊中的demo也不是很復雜,運行demo。
剛進入的界面是一個登陸界面,這里直接用手機號碼登陸,進入主界面
先看清單文件,ECApplication類是程序開啟加載的類,先不管。程序的主入口是一個LauncherActivity(主頁面tab),閱讀代碼可以看到,在進入的時候會在onResume()方法中判定,如果帳號為空就跳轉到登陸界面LoginActivity();
因為我這個項目就需要一個IM功能,用戶登陸的時候是手機驗證,所以在使用容聯云的時候,直接使用手機號碼登陸就可以了
@Override protected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);String mobile = mApplication.getTel(); //獲取手機號碼String pass = ""; //由于直接手機登陸,所以密碼為空String appKey = appkeyEt.getText().toString().trim();String token = tokenEt.getText().toString().trim();ClientUser clientUser = new ClientUser(mobile);clientUser.setAppKey(appKey);clientUser.setAppToken(token);clientUser.setLoginAuthType(mLoginAuthType);clientUser.setPassword(pass);CCPAppManager.setClientUser(clientUser);SDKCoreHelper.init(this, ECInitParams.LoginMode.FORCE_LOGIN);getTopBarView().setTopBarToStatus(1, -1,R.drawable.btn_style_green, null,getString(R.string.app_title_switch),getString(R.string.app_name), null, this);registerReceiver(new String[] { SDKCoreHelper.ACTION_SDK_CONNECT });} }// 注冊帳號 private void saveAccount() throws InvalidClassException {String appKey = appkeyEt.getText().toString().trim();String token = tokenEt.getText().toString().trim();String mobile = "13500000000";String voippass = mVoipEt.getText().toString().trim();ClientUser user = new ClientUser(mobile);user.setAppToken(token);user.setAppKey(appKey);user.setPassword(voippass);user.setLoginAuthType(mLoginAuthType);CCPAppManager.setClientUser(user);ECPreferences.savePreference(ECPreferenceSettings.SETTINGS_REGIST_AUTO,user.toString(), true);ArrayList<ECContacts> objects = ContactLogic.initContacts();objects = ContactLogic.converContacts(objects);ContactSqlManager.insertContacts(objects);}以上是一個登陸代碼,把demo中的不需要的可以直接刪除掉
總結
以上是生活随笔為你收集整理的容联云通讯的学习笔记二的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mac系统升到11后没游戏玩?植物大战僵
- 下一篇: Telerik UI 2022.R1.S