com.hyphenate.EMCallBack Java Examples
The following examples show how to use
com.hyphenate.EMCallBack.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MineFragment.java From Social with Apache License 2.0 | 6 votes |
private void logoutIMService(){ //此方法为异步方法 EMClient.getInstance().logout(true, new EMCallBack() { @Override public void onSuccess() { // TODO Auto-generated method stub Log.d("SocialMainActivity", "成功退出环信服务器"); } @Override public void onProgress(int progress, String status) { // TODO Auto-generated method stub } @Override public void onError(int code, String message) { // TODO Auto-generated method stub Log.d("SocialMainActivity", "还没退出环信服务器"); } }); }
Example #2
Source File: SettingFragment.java From Social with Apache License 2.0 | 6 votes |
private void logout(){ OkhttpUtil.logout(handler); //此方法为异步方法 EMClient.getInstance().logout(true, new EMCallBack() { @Override public void onSuccess() { // TODO Auto-generated method stub } @Override public void onProgress(int progress, String status) { // TODO Auto-generated method stub } @Override public void onError(int code, String message) { // TODO Auto-generated method stub } }); }
Example #3
Source File: SettingFragment.java From Social with Apache License 2.0 | 6 votes |
private void logoutIMService(){ //此方法为异步方法 EMClient.getInstance().logout(true, new EMCallBack() { @Override public void onSuccess() { // TODO Auto-generated method stub Log.d("SocialActivity", "成功退出环信服务器"); } @Override public void onProgress(int progress, String status) { // TODO Auto-generated method stub } @Override public void onError(int code, String message) { // TODO Auto-generated method stub Log.d("SocialActivity", "还没退出环信服务器"); } }); }
Example #4
Source File: MineFragment.java From Social with Apache License 2.0 | 6 votes |
private void logout(){ OkhttpUtil.logout(handler); //此方法为异步方法 EMClient.getInstance().logout(true, new EMCallBack() { @Override public void onSuccess() { // TODO Auto-generated method stub } @Override public void onProgress(int progress, String status) { // TODO Auto-generated method stub } @Override public void onError(int code, String message) { // TODO Auto-generated method stub } }); }
Example #5
Source File: HxSdkHelper.java From FamilyChat with Apache License 2.0 | 5 votes |
/** * 手动登录环信的方法 * * @param phone 手机号 * @param pwd 密码 * @param callBack 回调 */ public void login(final String phone, final String pwd, final FCCallBack callBack) { EMClient.getInstance().login(phone, pwd, new EMCallBack() { @Override public void onSuccess() { KLog.i("HxSdk login from server success"); loadHxLocalData(); if (callBack != null) callBack.onSuccess(null); } @Override public void onError(int code, String msg) { KLog.e("HxSdk login fail : hxErrCode = " + code + " , msg = " + msg); if (callBack != null) callBack.onFail(FCError.LOGIN_FAIL, FCError.getErrorMsgIdFromCode(code)); } @Override public void onProgress(int progress, String status) { } }); }
Example #6
Source File: AccountController.java From nono-android with GNU General Public License v3.0 | 5 votes |
private static void rightAfterLogOn(){ SeriesLogOnInfo.putInfo(MyApp.getInstance().getApplicationContext(), MyApp.userInfo.username, MyApp.userInfo.userpassword); EMClient.getInstance().login(MyApp.userInfo.userId,SHA1(MyApp.userInfo.userpassword) ,new EMCallBack() {//回调 @Override public void onSuccess() { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { EMClient.getInstance().groupManager().loadAllGroups(); EMClient.getInstance().chatManager().loadAllConversations(); Log.d("main", "登陆聊天服务器成功!"); } }); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { Log.d("main", "登陆聊天服务器失败!"); } }); MobclickAgent.onProfileSignIn(MyApp.userInfo.userId); NoteController.iniCloudSyncTask(); ServiceFactory.getAccountService().getAllNote(AuthBody.getAuthBodyMap()) .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<AuthorBean>() { @Override public void call(AuthorBean authorBean) { MyApp.getInstance().authorBean.author = authorBean.author; } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { } }); }
Example #7
Source File: HuanXinHelper.java From nono-android with GNU General Public License v3.0 | 5 votes |
/** * 退出登录 * * @param unbindDeviceToken * 是否解绑设备token(使用GCM才有) * @param callback * callback */ public void logout(boolean unbindDeviceToken, final EMCallBack callback) { Log.d(TAG, "logout: " + unbindDeviceToken); EMClient.getInstance().logout(unbindDeviceToken, new EMCallBack() { @Override public void onSuccess() { Log.d(TAG, "logout: onSuccess"); reset(); if (callback != null) { callback.onSuccess(); } } @Override public void onProgress(int progress, String status) { if (callback != null) { callback.onProgress(progress, status); } } @Override public void onError(int code, String error) { Log.d(TAG, "logout: onSuccess"); reset(); if (callback != null) { callback.onError(code, error); } } }); }
Example #8
Source File: SettingsFragment.java From Study_Android_Demo with Apache License 2.0 | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Button logoutButton = (Button) getView().findViewById(R.id.btn_logout); logoutButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { EMClient.getInstance().logout(false, new EMCallBack() { @Override public void onSuccess() { getActivity().finish(); startActivity(new Intent(getActivity(), LoginActivity.class)); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String error) { } }); } }); }
Example #9
Source File: HostMonitor.java From Social with Apache License 2.0 | 5 votes |
private void loginHuanxinAndJpush(){ //登录环信 //登录app服务器成功后登录环信服务器 EMClient.getInstance().login(SharedPreferenceUtil.getUserName(), SharedPreferenceUtil.getPassword(), new EMCallBack() {//回调 @Override public void onSuccess() { new Thread(new Runnable() { @Override public void run() { EMClient.getInstance().groupManager().loadAllGroups(); EMClient.getInstance().chatManager().loadAllConversations(); Log.d(TAG, "登陆聊天服务器成功!"); } }).start(); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { Log.d(TAG, "登陆聊天服务器失败!\n" + message); } }); JPushInterface.setAlias(this, SharedPreferenceUtil.getUserName(), new TagAliasCallback() { @Override public void gotResult(int i, String s, Set<String> set) { } }); }
Example #10
Source File: EaseShowNormalFileActivity.java From Social with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ease_activity_show_file); progressBar = (ProgressBar) findViewById(R.id.progressBar); final EMFileMessageBody messageBody = getIntent().getParcelableExtra("msgbody"); file = new File(messageBody.getLocalUrl()); //set head map final Map<String, String> maps = new HashMap<String, String>(); if (!TextUtils.isEmpty(messageBody.getSecret())) { maps.put("share-secret", messageBody.getSecret()); } //下载文件 EMClient.getInstance().chatManager().downloadFile(messageBody.getRemoteUrl(), messageBody.getLocalUrl(), maps, new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { public void run() { FileUtils.openFile(file, EaseShowNormalFileActivity.this); finish(); } }); } @Override public void onProgress(final int progress,String status) { runOnUiThread(new Runnable() { public void run() { progressBar.setProgress(progress); } }); } @Override public void onError(int error, final String msg) { runOnUiThread(new Runnable() { public void run() { if(file != null && file.exists()&&file.isFile()) file.delete(); String str4 = getResources().getString(R.string.Failed_to_download_file); Toast.makeText(EaseShowNormalFileActivity.this, str4+msg, Toast.LENGTH_SHORT).show(); finish(); } }); } }); }
Example #11
Source File: EaseShowVideoActivity.java From Social with Apache License 2.0 | 4 votes |
/** * 下载视频文件 */ private void downloadVideo(final String remoteUrl, final Map<String, String> header) { if (TextUtils.isEmpty(localFilePath)) { localFilePath = getLocalFilePath(remoteUrl); } if (new File(localFilePath).exists()) { showLocalVideo(localFilePath); return; } loadingLayout.setVisibility(View.VISIBLE); EMCallBack callback = new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { @Override public void run() { loadingLayout.setVisibility(View.GONE); progressBar.setProgress(0); showLocalVideo(localFilePath); } }); } @Override public void onProgress(final int progress,String status) { Log.d("ease", "video progress:" + progress); runOnUiThread(new Runnable() { @Override public void run() { progressBar.setProgress(progress); } }); } @Override public void onError(int error, String msg) { Log.e("###", "offline file transfer error:" + msg); File file = new File(localFilePath); if (file.exists()) { file.delete(); } } }; EMClient.getInstance().chatManager().downloadFile(remoteUrl, localFilePath, header, callback); }
Example #12
Source File: EaseShowNormalFileActivity.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.ease_activity_show_file); progressBar = (ProgressBar) findViewById(R.id.progressBar); final EMFileMessageBody messageBody = getIntent().getParcelableExtra("msgbody"); file = new File(messageBody.getLocalUrl()); //set head map final Map<String, String> maps = new HashMap<String, String>(); if (!TextUtils.isEmpty(messageBody.getSecret())) { maps.put("share-secret", messageBody.getSecret()); } //download file EMClient.getInstance().chatManager().downloadFile(messageBody.getRemoteUrl(), messageBody.getLocalUrl(), maps, new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { public void run() { FileUtils.openFile(file, EaseShowNormalFileActivity.this); finish(); } }); } @Override public void onProgress(final int progress,String status) { runOnUiThread(new Runnable() { public void run() { progressBar.setProgress(progress); } }); } @Override public void onError(int error, final String msg) { runOnUiThread(new Runnable() { public void run() { if(file != null && file.exists()&&file.isFile()) file.delete(); String str4 = getResources().getString(R.string.Failed_to_download_file); Toast.makeText(EaseShowNormalFileActivity.this, str4+msg, Toast.LENGTH_SHORT).show(); finish(); } }); } }); }
Example #13
Source File: EaseShowVideoActivity.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
/** * download video file */ private void downloadVideo(final String remoteUrl, final Map<String, String> header) { if (TextUtils.isEmpty(localFilePath)) { localFilePath = getLocalFilePath(remoteUrl); } if (new File(localFilePath).exists()) { showLocalVideo(localFilePath); return; } loadingLayout.setVisibility(View.VISIBLE); EMCallBack callback = new EMCallBack() { @Override public void onSuccess() { runOnUiThread(new Runnable() { @Override public void run() { loadingLayout.setVisibility(View.GONE); progressBar.setProgress(0); showLocalVideo(localFilePath); } }); } @Override public void onProgress(final int progress,String status) { Log.d("ease", "video progress:" + progress); runOnUiThread(new Runnable() { @Override public void run() { progressBar.setProgress(progress); } }); } @Override public void onError(int error, String msg) { Log.e("###", "offline file transfer error:" + msg); File file = new File(localFilePath); if (file.exists()) { file.delete(); } } }; EMClient.getInstance().chatManager().downloadFile(remoteUrl, localFilePath, header, callback); }
Example #14
Source File: EaseShowBigImageActivity.java From Social with Apache License 2.0 | 4 votes |
/** * 下载图片 * * @param remoteFilePath */ private void downloadImage(final String remoteFilePath, final Map<String, String> headers) { String str1 = getResources().getString(R.string.Download_the_pictures); pd = new ProgressDialog(this); pd.setProgressStyle(ProgressDialog.STYLE_SPINNER); pd.setCanceledOnTouchOutside(false); pd.setMessage(str1); pd.show(); File temp = new File(localFilePath); final String tempPath = temp.getParent() + "/temp_" + temp.getName(); final EMCallBack callback = new EMCallBack() { public void onSuccess() { runOnUiThread(new Runnable() { @Override public void run() { new File(tempPath).renameTo(new File(localFilePath)); DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int screenWidth = metrics.widthPixels; int screenHeight = metrics.heightPixels; bitmap = ImageUtils.decodeScaleImage(localFilePath, screenWidth, screenHeight); if (bitmap == null) { image.setImageResource(default_res); } else { image.setImageBitmap(bitmap); EaseImageCache.getInstance().put(localFilePath, bitmap); isDownloaded = true; } if (EaseShowBigImageActivity.this.isFinishing() || EaseShowBigImageActivity.this.isDestroyed()) { return; } if (pd != null) { pd.dismiss(); } } }); } public void onError(int error, String msg) { EMLog.e(TAG, "offline file transfer error:" + msg); File file = new File(tempPath); if (file.exists()&&file.isFile()) { file.delete(); } runOnUiThread(new Runnable() { @Override public void run() { if (EaseShowBigImageActivity.this.isFinishing() || EaseShowBigImageActivity.this.isDestroyed()) { return; } image.setImageResource(default_res); pd.dismiss(); } }); } public void onProgress(final int progress, String status) { EMLog.d(TAG, "Progress: " + progress); final String str2 = getResources().getString(R.string.Download_the_pictures_new); runOnUiThread(new Runnable() { @Override public void run() { if (EaseShowBigImageActivity.this.isFinishing() || EaseShowBigImageActivity.this.isDestroyed()) { return; } pd.setMessage(str2 + progress + "%"); } }); } }; EMClient.getInstance().chatManager().downloadFile(remoteFilePath, tempPath, headers, callback); }
Example #15
Source File: LoginActivity.java From Study_Android_Demo with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle arg0) { super.onCreate(arg0); if(EMClient.getInstance().isLoggedInBefore()){ //enter to main activity directly if you logged in before. 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) { //login 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(); } }); } }); } }); }
Example #16
Source File: LongConnectionService.java From Social with Apache License 2.0 | 4 votes |
@Override public int onStartCommand(final Intent intent, int flags, int startId) { //每隔一分钟自动登录一次 Intent intentLocationService =new Intent(LongConnectionService.this,BDLocationService.class); startService(intentLocationService); count++; //Toast.makeText(this,"每隔1分钟登录一次\n已登录" + count + "次.",Toast.LENGTH_LONG).show(); Log.d(TAG,"每隔1分钟登录一次\n已登录" + count + "次."); //Log.d("StartService", "登陆聊天服务器成功!"); if (SharedPreferenceUtil.getUserName()!=null && SharedPreferenceUtil.getPassword()!=null){ if (!SharedPreferenceUtil.getUserName().equals("") && !SharedPreferenceUtil.getPassword().equals("")){ //登录环信 //登录app服务器成功后登录环信服务器 EMClient.getInstance().login(SharedPreferenceUtil.getUserName(), SharedPreferenceUtil.getPassword(), new EMCallBack() {//回调 @Override public void onSuccess() { new Thread(new Runnable() { @Override public void run() { EMClient.getInstance().groupManager().loadAllGroups(); EMClient.getInstance().chatManager().loadAllConversations(); Log.d(TAG, "登陆聊天服务器成功!"); } }).start(); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { Log.d(TAG, "登陆聊天服务器失败!\n" + message); } }); } } handler = new Handler(){ @Override public void handleMessage(Message msg) { switch (msg.what){ case OkhttpUtil.MESSAGE_POLL_SERVICE: handlePollService(msg); break; } } }; OkhttpUtil.pollServive(handler); AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE); int ten_min = 60*1000*1;//1分钟; //int ten_min = 30*1000; long triggerAtTime = SystemClock.elapsedRealtime() + ten_min; Intent i = new Intent(this,LongConnectionAlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this,0,i,0); alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,triggerAtTime,pendingIntent); flags = START_STICKY; return super.onStartCommand(intent, flags, startId); }
Example #17
Source File: LoginPresenter.java From Social with Apache License 2.0 | 4 votes |
private void handleLogin(Context context, String result, String pwd) { Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd").create(); Type type = new TypeToken<Response<User>>() {}.getType(); Response<User> root = gson.fromJson(result,type); if (root == null){ mViewRef.get().showErrorMessageToast(root.getMessage()); return; } if (!root.isSuccess()){ mViewRef.get().showTipsDialog(root.getMessage()); return ; } mViewRef.get().loginSuccess(); //登录成功后为每个用户设置别名:username User user = root.getData(); JPushInterface.setAlias(context, root.getData().getUsername(), new TagAliasCallback() { @Override public void gotResult(int i, String s, Set<String> set) { Log.d("JPush", i + ""); } }); //登录app服务器成功后登录环信服务器 EMClient.getInstance().login(user.getUsername(), pwd, new EMCallBack() {//回调 @Override public void onSuccess() { new Thread(new Runnable() { @Override public void run() { EMClient.getInstance().groupManager().loadAllGroups(); EMClient.getInstance().chatManager().loadAllConversations(); Log.d("LoninFragment", "登陆聊天服务器成功!"); } }).start(); } @Override public void onProgress(int progress, String status) { } @Override public void onError(int code, String message) { Log.d("LoninFragment", "登陆聊天服务器失败!"); } }); SharedPreferenceUtil.setUserId(user.getId()); SharedPreferenceUtil.setUsername(user.getUsername()); SharedPreferenceUtil.setNickname(user.getNickname()); SharedPreferenceUtil.setPassword(pwd); SharedPreferenceUtil.setHeadpath(user.getUser_head_path()); SharedPreferenceUtil.setSignature(user.getSignature()); SharedPreferenceUtil.setState("1"); SharedPreferenceUtil.setSessionId(root.getSession_id()); SharedPreferenceUtil.setCity(user.getCity()); SharedPreferenceUtil.setSex(user.getSex()); SharedPreferenceUtil.setPhone(user.getPhone()); SharedPreferenceUtil.setEmail(user.getEmail()); SharedPreferenceUtil.setAge(user.getAge()); SharedPreferenceUtil.setOccupation(user.getOccupation()); SharedPreferenceUtil.setConstellation(user.getConstellation()); SharedPreferenceUtil.setHihgt(user.getHight()); SharedPreferenceUtil.setWeight(user.getWeight()); SharedPreferenceUtil.setFigure(user.getFigure()); SharedPreferenceUtil.setEmotion(user.getEmotion()); SharedPreferenceUtil.setVip(user.getIs_vip() + ""); SharedPreferenceUtil.setRecommend(user.getIs_recommended() + ""); SharedPreferenceUtil.setAutoReaction(user.getAutoreaction()); SharedPreferenceUtil.setOnlineState(user.getOnlinestate()); SharedPreferenceUtil.setOpenid(user.getQq_open_id()); }