您的位置:首页 > 其它

容联云通讯的学习笔记二

2015-09-23 11:27 281 查看
先把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 = "17096063064";
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中的不需要的可以直接删除掉
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: