本文整理汇总了Java中com.easemob.chat.EMChat类的典型用法代码示例。如果您正苦于以下问题:Java EMChat类的具体用法?Java EMChat怎么用?Java EMChat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EMChat类属于com.easemob.chat包,在下文中一共展示了EMChat类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadLoginData
import com.easemob.chat.EMChat; //导入依赖的package包/类
/**
* 处理登陆数据
*
* @param resposne
*/
private void loadLoginData(CommonResponse resposne) {
// if (resposne.isSuccess()) {
SharedPreferencesHelper.setString(this, Constant.LoginUser.SHARED_PREFERENCES_PHONE, phone);
SharedPreferencesHelper.setString(this, Constant.LoginUser.SHARED_PREFERENCES_PASSWORD, password);
UserInfo userInfo = UserInfo.testData();
String userJson = JSON.toJSONString(userInfo);
SharedPreferencesHelper.setString(this, Constant.LoginUser.SHARED_PREFERENCES_USER, userJson);
App.getInstance().setgUserInfo(userInfo);
if (!EMChat.getInstance().isLoggedIn()) {
EASEMOBLogin();
} else {
dialogDismiss();
EMGroupManager.getInstance().loadAllGroups();
EMChatManager.getInstance().loadAllConversations();
toMainActivity();
}
// } else {
// dialogDismiss();
// CommonUtil.showToast(resposne.getErrorTip());
// }
}
开发者ID:tengbinlive,项目名称:info_demo,代码行数:27,代码来源:LoginActivity.java
示例2: init
import com.easemob.chat.EMChat; //导入依赖的package包/类
/**
* init helper
*
* @param context application context
*/
public void init(Context context) {
if (EaseUI.getInstance().init(context)) {
appContext = context;
//设为调试模式,打成正式包时,最好设为false,以免消耗额外的资源
EMChat.getInstance().setDebugMode(true);
//get easeui instance
easeUI = EaseUI.getInstance();
//调用easeui的api设置providers
setEaseUIProviders();
demoModel = new DemoModel(context);
//设置chat options
setChatoptions();
//初始化PreferenceManager
PreferenceManager.init(context);
//初始化用户管理类
getUserProfileManager().init(context);
//设置全局监听
setGlobalListeners();
broadcastManager = LocalBroadcastManager.getInstance(appContext);
initDbDao();
}
}
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:29,代码来源:DemoHelper.java
示例3: init
import com.easemob.chat.EMChat; //导入依赖的package包/类
/**
*this function will initialize the HuanXin SDK
*
* @return boolean true if caller can continue to call HuanXin related APIs after calling onInit, otherwise false.
*
* 初始化环信sdk及easeui库
* 返回true如果正确初始化,否则false,如果返回为false,请在后续的调用中不要调用任何和环信相关的代码
* @param context
* @return
*/
public synchronized boolean init(Context context){
if(sdkInited){
return true;
}
appContext = context;
int pid = android.os.Process.myPid();
String processAppName = getAppName(pid);
Log.d(TAG, "process app name : " + processAppName);
// 如果app启用了远程的service,此application:onCreate会被调用2次
// 为了防止环信SDK被初始化2次,加此判断会保证SDK被初始化1次
// 默认的app会在以包名为默认的process name下运行,如果查到的process name不是app的process name就立即返回
if (processAppName == null || !processAppName.equalsIgnoreCase(appContext.getPackageName())) {
Log.e(TAG, "enter the service process!");
// 则此application::onCreate 是被service 调用的,直接返回
return false;
}
// 初始化环信SDK,一定要先调用init()
EMChat.getInstance().init(context);
initChatOptions();
if(settingsProvider == null){
settingsProvider = new DefaultSettingsProvider();
}
sdkInited = true;
return true;
}
开发者ID:huijimuhe,项目名称:monolog-android,代码行数:41,代码来源:EaseUI.java
示例4: init
import com.easemob.chat.EMChat; //导入依赖的package包/类
/**
* init helper
*
* @param context
* application context
*/
public void init(Context context) {
if (EaseUI.getInstance().init(context)) {
appContext = context;
//if your app is supposed to user Google Push, please set project number
String projectNumber = "562451699741";
//不使用GCM推送的注释掉这行
EMChatManager.getInstance().setGCMProjectNumber(projectNumber);
//在小米手机上当app被kill时使用小米推送进行消息提示,同GCM一样不是必须的
EMChatManager.getInstance().setMipushConfig("2882303761517370134", "5131737040134");
//设为调试模式,打成正式包时,最好设为false,以免消耗额外的资源
EMChat.getInstance().setDebugMode(true);
//get easeui instance
easeUI = EaseUI.getInstance();
//调用easeui的api设置providers
setEaseUIProviders();
demoModel = new DemoModel(context);
//设置chat options
setChatoptions();
//初始化PreferenceManager
PreferenceManager.init(context);
//初始化用户管理类
getUserProfileManager().init(context);
//设置全局监听
setGlobalListeners();
broadcastManager = LocalBroadcastManager.getInstance(appContext);
initDbDao();
}
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:39,代码来源:DemoHelper.java
示例5: notifyForRecevingEvents
import com.easemob.chat.EMChat; //导入依赖的package包/类
public synchronized void notifyForRecevingEvents(){
if(alreadyNotified){
return;
}
// 通知sdk,UI 已经初始化完毕,注册了相应的receiver和listener, 可以接受broadcast了
EMChat.getInstance().setAppInited();
alreadyNotified = true;
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:10,代码来源:DemoHelper.java
示例6: asyncFetchContactInfosFromServer
import com.easemob.chat.EMChat; //导入依赖的package包/类
public void asyncFetchContactInfosFromServer(List<String> usernames, final EMValueCallBack<List<EaseUser>> callback) {
if (isSyncingContactInfosWithServer) {
return;
}
isSyncingContactInfosWithServer = true;
ParseManager.getInstance().getContactInfos(usernames, new EMValueCallBack<List<EaseUser>>() {
@Override
public void onSuccess(List<EaseUser> value) {
isSyncingContactInfosWithServer = false;
// in case that logout already before server returns,we should
// return immediately
if (!EMChat.getInstance().isLoggedIn()) {
return;
}
if (callback != null) {
callback.onSuccess(value);
}
}
@Override
public void onError(int error, String errorMsg) {
isSyncingContactInfosWithServer = false;
if (callback != null) {
callback.onError(error, errorMsg);
}
}
});
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:32,代码来源:UserProfileManager.java
示例7: init
import com.easemob.chat.EMChat; //导入依赖的package包/类
/**
* this function will initialize the HuanXin SDK
*
* @return boolean true if caller can continue to call HuanXin related APIs
* after calling onInit, otherwise false.
*
* 初始化环信sdk及easeui库
* 返回true如果正确初始化,否则false,如果返回为false,请在后续的调用中不要调用任何和环信相关的代码
* @param context
* @return
*/
public synchronized boolean init(Context context) {
if (sdkInited) {
return true;
}
appContext = context;
int pid = android.os.Process.myPid();
String processAppName = getAppName(pid);
Log.d(TAG, "process app name : " + processAppName);
// 如果app启用了远程的service,此application:onCreate会被调用2次
// 为了防止环信SDK被初始化2次,加此判断会保证SDK被初始化1次
// 默认的app会在以包名为默认的process name下运行,如果查到的process name不是app的process
// name就立即返回
if (processAppName == null || !processAppName.equalsIgnoreCase(appContext.getPackageName())) {
Log.e(TAG, "enter the service process!");
// 则此application::onCreate 是被service 调用的,直接返回
return false;
}
// 初始化环信SDK,一定要先调用init()
EMChat.getInstance().init(context);
initChatOptions();
if (settingsProvider == null) {
settingsProvider = new DefaultSettingsProvider();
}
sdkInited = true;
return true;
}
开发者ID:easemob,项目名称:easeui,代码行数:44,代码来源:EaseUI.java
示例8: asyncFetchGroupsFromServer
import com.easemob.chat.EMChat; //导入依赖的package包/类
/**
* 同步操作,从服务器获取群组列表
* 该方法会记录更新状态,可以通过isSyncingGroupsFromServer获取是否正在更新
* 和HXPreferenceUtils.getInstance().getSettingSyncGroupsFinished()获取是否更新已经完成
* @throws EaseMobException
*/
public synchronized void asyncFetchGroupsFromServer(final EMCallBack callback){
if(isSyncingGroupsWithServer){
return;
}
isSyncingGroupsWithServer = true;
new Thread(){
@Override
public void run(){
try {
EMGroupManager.getInstance().getGroupsFromServer();
// in case that logout already before server returns, we should return immediately
if(!EMChat.getInstance().isLoggedIn()){
return;
}
hxModel.setGroupsSynced(true);
isGroupsSyncedWithServer = true;
isSyncingGroupsWithServer = false;
if(callback != null){
callback.onSuccess();
}
} catch (EaseMobException e) {
hxModel.setGroupsSynced(false);
isGroupsSyncedWithServer = false;
isSyncingGroupsWithServer = false;
if(callback != null){
callback.onError(e.getErrorCode(), e.toString());
}
}
}
}.start();
}
开发者ID:chenjunqian,项目名称:here,代码行数:44,代码来源:HXSDKHelper.java
示例9: asyncFetchContactsFromServer
import com.easemob.chat.EMChat; //导入依赖的package包/类
public void asyncFetchContactsFromServer(final EMValueCallBack<List<String>> callback){
if(isSyncingContactsWithServer){
return;
}
isSyncingContactsWithServer = true;
new Thread(){
@Override
public void run(){
List<String> usernames = null;
try {
usernames = EMContactManager.getInstance().getContactUserNames();
// in case that logout already before server returns, we should return immediately
if(!EMChat.getInstance().isLoggedIn()){
return;
}
hxModel.setContactSynced(true);
isContactsSyncedWithServer = true;
isSyncingContactsWithServer = false;
if(callback != null){
callback.onSuccess(usernames);
}
} catch (EaseMobException e) {
hxModel.setContactSynced(false);
isContactsSyncedWithServer = false;
isSyncingContactsWithServer = false;
e.printStackTrace();
if(callback != null){
callback.onError(e.getErrorCode(), e.toString());
}
}
}
}.start();
}
开发者ID:chenjunqian,项目名称:here,代码行数:40,代码来源:HXSDKHelper.java
示例10: asyncFetchContactInfosFromServer
import com.easemob.chat.EMChat; //导入依赖的package包/类
public void asyncFetchContactInfosFromServer(List<String> usernames, final EMValueCallBack<List<EMUser>> callback) {
if (isSyncingContactInfosWithServer) {
return;
}
isSyncingContactInfosWithServer = true;
ParseManager.getInstance().getContactInfos(usernames, new EMValueCallBack<List<EMUser>>() {
@Override
public void onSuccess(List<EMUser> value) {
isSyncingContactInfosWithServer = false;
// in case that logout already before server returns,we should
// return immediately
if (!EMChat.getInstance().isLoggedIn()) {
return;
}
if (callback != null) {
callback.onSuccess(value);
}
}
@Override
public void onError(int error, String errorMsg) {
isSyncingContactInfosWithServer = false;
if (callback != null) {
callback.onError(error, errorMsg);
}
}
});
}
开发者ID:chenjunqian,项目名称:here,代码行数:32,代码来源:UserProfileManager.java
示例11: notifyForRecevingEvents
import com.easemob.chat.EMChat; //导入依赖的package包/类
public synchronized void notifyForRecevingEvents() {
if (alreadyNotified) {
return;
}
// 通知sdk,UI 已经初始化完毕,注册了相应的receiver和listener, 可以接受broadcast了
EMChat.getInstance().setAppInited();
alreadyNotified = true;
}
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:10,代码来源:DemoHelper.java
示例12: asyncFetchContactInfosFromServer
import com.easemob.chat.EMChat; //导入依赖的package包/类
public void asyncFetchContactInfosFromServer(List<String> usernames, final EMValueCallBack<List<EaseUser>> callback) {
if (isSyncingContactInfosWithServer) {
return;
}
isSyncingContactInfosWithServer = true;
ParseManager.getInstance().getContactInfos(usernames, new EMValueCallBack<List<EaseUser>>() {
@Override
public void onSuccess(List<EaseUser> value) {
isSyncingContactInfosWithServer = false;
// in case that logout already before server returns,we should
// return immediately
if (!EMChat.getInstance().isLoggedIn()) {
return;
}
if (callback != null) {
callback.onSuccess(value);
}
}
@Override
public void onError(int error, String errorMsg) {
isSyncingContactInfosWithServer = false;
if (callback != null) {
callback.onError(error, errorMsg);
}
}
});
}
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:32,代码来源:UserProfileManager.java
示例13: init
import com.easemob.chat.EMChat; //导入依赖的package包/类
/**
* this function will initialize the HuanXin SDK
*
* @param context
* @return
*/
public synchronized boolean init(Context context) {
if (sdkInited) {
return true;
}
appContext = context;
int pid = android.os.Process.myPid();
String processAppName = getAppName(pid);
Log.d(TAG, "process app name : " + processAppName);
// 如果app启用了远程的service,此application:onCreate会被调用2次
// 为了防止环信SDK被初始化2次,加此判断会保证SDK被初始化1次
// 默认的app会在以包名为默认的process name下运行,如果查到的process name不是app的process name就立即返回
if (processAppName == null || !processAppName.equalsIgnoreCase(appContext.getPackageName())) {
Log.e(TAG, "enter the service process!");
// 则此application::onCreate 是被service 调用的,直接返回
return false;
}
// 初始化环信SDK,一定要先调用init()
EMChat.getInstance().init(context);
initChatOptions();
if (settingsProvider == null) {
settingsProvider = new DefaultSettingsProvider();
}
sdkInited = true;
return true;
}
开发者ID:nggirl,项目名称:EaseChatDemo,代码行数:38,代码来源:EaseUI.java
示例14: onCreate
import com.easemob.chat.EMChat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//设置推送昵称
DemoApplication.currentUserNick = DemoApplication.getInstance().getUsernNickName();
initView();
inviteMessgeDao = new InviteMessgeDao(this);
userDao = new UserDao(this);
zainaFrament = new ZainaFragment();
gushiFrament = new Zaina_gushi_Fragment();
//这个fragment只显示好友和群组的聊天记录
// chatHistoryFragment = new ChatHistoryFragment();
//显示所有人消息记录的fragment
chatHistoryFragment = new ChatAllHistoryFragment();
contactListFragment = new ContactlistFragment();
settingFragment = new SettingsFragment();
//fragments = new Fragment[] { chatHistoryFragment, contactListFragment, settingFragment };
fragments = new Fragment[] { zainaFrament , gushiFrament , chatHistoryFragment, contactListFragment, settingFragment };
// 添加显示第一个fragment
/* getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, chatHistoryFragment)
.add(R.id.fragment_container, contactListFragment).hide(contactListFragment).show(chatHistoryFragment)
.commit();*/
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, zainaFrament)
.add(R.id.fragment_container, contactListFragment).hide(contactListFragment).show(chatHistoryFragment)
.commit();
// 注册一个接收消息的BroadcastReceiver
msgReceiver = new NewMessageBroadcastReceiver();
IntentFilter intentFilter = new IntentFilter(EMChatManager.getInstance().getNewMessageBroadcastAction());
intentFilter.setPriority(3);
registerReceiver(msgReceiver, intentFilter);
// 注册一个ack回执消息的BroadcastReceiver
IntentFilter ackMessageIntentFilter = new IntentFilter(EMChatManager.getInstance()
.getAckMessageBroadcastAction());
ackMessageIntentFilter.setPriority(3);
registerReceiver(ackMessageReceiver, ackMessageIntentFilter);
// 注册一个离线消息的BroadcastReceiver
IntentFilter offlineMessageIntentFilter = new IntentFilter(EMChatManager.getInstance()
.getOfflineMessageBroadcastAction());
registerReceiver(offlineMessageReceiver, offlineMessageIntentFilter);
// setContactListener监听联系人的变化等
EMContactManager.getInstance().setContactListener(new MyContactListener());
// 注册一个监听连接状态的listener
EMChatManager.getInstance().addConnectionListener(new MyConnectionListener());
// 注册群聊相关的listener
EMGroupManager.getInstance().addGroupChangeListener(new MyGroupChangeListener());
// 通知sdk,UI 已经初始化完毕,注册了相应的receiver和listener, 可以接受broadcast了
EMChat.getInstance().setAppInited();
/****新增****/
loadcontact();
//showFloatingButton();暂时注释
}
开发者ID:macyuan,项目名称:TAG,代码行数:59,代码来源:MainActivity_0903.java
示例15: uploadlog
import com.easemob.chat.EMChat; //导入依赖的package包/类
public void uploadlog() {
if (progressDialog == null)
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("上传日志中...");
progressDialog.setCancelable(false);
progressDialog.show();
EMChat.getInstance().uploadLog(new EMCallBack() {
@Override
public void onSuccess() {
runOnUiThread(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
Toast.makeText(DiagnoseActivity.this, "日志上传成功",
Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onProgress(final int progress, String status) {
// getActivity().runOnUiThread(new Runnable() {
//
// @Override
// public void run() {
// progressDialog.setMessage("上传中 "+progress+"%");
//
// }
// });
}
@Override
public void onError(int code, String message) {
EMLog.e("###", message);
runOnUiThread(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
Toast.makeText(DiagnoseActivity.this, "log上传失败",
Toast.LENGTH_SHORT).show();
}
});
}
});
}
开发者ID:macyuan,项目名称:TAG,代码行数:54,代码来源:DiagnoseActivity.java
示例16: asyncFetchGroupsFromServer
import com.easemob.chat.EMChat; //导入依赖的package包/类
/**
* 同步操作,从服务器获取群组列表
* 该方法会记录更新状态,可以通过isSyncingGroupsFromServer获取是否正在更新
* 和isGroupsSyncedWithServer获取是否更新已经完成
* @throws EaseMobException
*/
public synchronized void asyncFetchGroupsFromServer(final EMCallBack callback){
if(isSyncingGroupsWithServer){
return;
}
isSyncingGroupsWithServer = true;
new Thread(){
@Override
public void run(){
try {
EMGroupManager.getInstance().getGroupsFromServer();
// in case that logout already before server returns, we should return immediately
if(!EMChat.getInstance().isLoggedIn()){
return;
}
demoModel.setGroupsSynced(true);
isGroupsSyncedWithServer = true;
isSyncingGroupsWithServer = false;
//通知listener同步群组完毕
noitifyGroupSyncListeners(true);
if(isContactsSyncedWithServer()){
notifyForRecevingEvents();
}
if(callback != null){
callback.onSuccess();
}
} catch (EaseMobException e) {
demoModel.setGroupsSynced(false);
isGroupsSyncedWithServer = false;
isSyncingGroupsWithServer = false;
noitifyGroupSyncListeners(false);
if(callback != null){
callback.onError(e.getErrorCode(), e.toString());
}
}
}
}.start();
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:51,代码来源:DemoHelper.java
示例17: asyncFetchContactsFromServer
import com.easemob.chat.EMChat; //导入依赖的package包/类
public void asyncFetchContactsFromServer(final EMValueCallBack<List<String>> callback){
if(isSyncingContactsWithServer){
return;
}
isSyncingContactsWithServer = true;
new Thread(){
@Override
public void run(){
List<String> usernames = null;
try {
usernames = EMContactManager.getInstance().getContactUserNames();
// in case that logout already before server returns, we should return immediately
if(!EMChat.getInstance().isLoggedIn()){
return;
}
Map<String, EaseUser> userlist = new HashMap<String, EaseUser>();
for (String username : usernames) {
EaseUser user = new EaseUser(username);
EaseCommonUtils.setUserInitialLetter(user);
userlist.put(username, user);
}
// 存入内存
getContactList().clear();
getContactList().putAll(userlist);
// 存入db
UserDao dao = new UserDao(appContext);
List<EaseUser> users = new ArrayList<EaseUser>(userlist.values());
dao.saveContactList(users);
demoModel.setContactSynced(true);
EMLog.d(TAG, "set contact syn status to true");
isContactsSyncedWithServer = true;
isSyncingContactsWithServer = false;
//通知listeners联系人同步完毕
notifyContactsSyncListener(true);
if(isGroupsSyncedWithServer()){
notifyForRecevingEvents();
}
getUserProfileManager().asyncFetchContactInfosFromServer(usernames,new EMValueCallBack<List<EaseUser>>() {
@Override
public void onSuccess(List<EaseUser> uList) {
updateContactList(uList);
getUserProfileManager().notifyContactInfosSyncListener(true);
}
@Override
public void onError(int error, String errorMsg) {
}
});
if(callback != null){
callback.onSuccess(usernames);
}
} catch (EaseMobException e) {
demoModel.setContactSynced(false);
isContactsSyncedWithServer = false;
isSyncingContactsWithServer = false;
noitifyGroupSyncListeners(false);
e.printStackTrace();
if(callback != null){
callback.onError(e.getErrorCode(), e.toString());
}
}
}
}.start();
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:75,代码来源:DemoHelper.java
示例18: asyncFetchBlackListFromServer
import com.easemob.chat.EMChat; //导入依赖的package包/类
public void asyncFetchBlackListFromServer(final EMValueCallBack<List<String>> callback){
if(isSyncingBlackListWithServer){
return;
}
isSyncingBlackListWithServer = true;
new Thread(){
@Override
public void run(){
try {
List<String> usernames = EMContactManager.getInstance().getBlackListUsernamesFromServer();
// in case that logout already before server returns, we should return immediately
if(!EMChat.getInstance().isLoggedIn()){
return;
}
demoModel.setBlacklistSynced(true);
isBlackListSyncedWithServer = true;
isSyncingBlackListWithServer = false;
EMContactManager.getInstance().saveBlackList(usernames);
notifyBlackListSyncListener(true);
if(callback != null){
callback.onSuccess(usernames);
}
} catch (EaseMobException e) {
demoModel.setBlacklistSynced(false);
isBlackListSyncedWithServer = false;
isSyncingBlackListWithServer = true;
e.printStackTrace();
if(callback != null){
callback.onError(e.getErrorCode(), e.toString());
}
}
}
}.start();
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:45,代码来源:DemoHelper.java
示例19: uploadlog
import com.easemob.chat.EMChat; //导入依赖的package包/类
public void uploadlog() {
if (progressDialog == null)
progressDialog = new ProgressDialog(this);
String stri = getResources().getString(R.string.Upload_the_log);
progressDialog.setMessage(stri);
progressDialog.setCancelable(false);
progressDialog.show();
final String st = getResources().getString(R.string.Log_uploaded_successfully);
EMChat.getInstance().uploadLog(new EMCallBack() {
@Override
public void onSuccess() {
runOnUiThread(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
Toast.makeText(DiagnoseActivity.this, st,
Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onProgress(final int progress, String status) {
// getActivity().runOnUiThread(new Runnable() {
//
// @Override
// public void run() {
// progressDialog.setMessage("上传中 "+progress+"%");
//
// }
// });
}
String st3 = getResources().getString(R.string.Log_Upload_failed);
@Override
public void onError(int code, String message) {
EMLog.e("###", message);
runOnUiThread(new Runnable() {
@Override
public void run() {
progressDialog.dismiss();
Toast.makeText(DiagnoseActivity.this, st3,
Toast.LENGTH_SHORT).show();
}
});
}
});
}
开发者ID:easemob,项目名称:sdkdemoapp3.0_android,代码行数:55,代码来源:DiagnoseActivity.java
示例20: onCreate
import com.easemob.chat.EMChat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
if(EMChat.getInstance().isLoggedIn()){
//登录过直接进入主页面
startActivity(new Intent(this, MainActivity.class));
finish();
}
setContentView(R.layout.activity_login);
usernameView = (EditText) findViewById(R.id.et_username);
pwdView = (EditText) findViewById(R.id.et_password);
Button loginBtn = (Button) findViewById(R.id.btn_login);
loginBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//登录
EMChatManager.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(), "登录失败", 0).show();
}
});
}
});
}
});
}
开发者ID:easemob,项目名称:easeui,代码行数:46,代码来源:LoginActivity.java
注:本文中的com.easemob.chat.EMChat类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论