@Override public void logout(final EMCallBack callback) { endCall(); super.logout( new EMCallBack() { @Override public void onSuccess() { // TODO Auto-generated method stub setContactList(null); getModel().closeDB(); if (callback != null) { callback.onSuccess(); } } @Override public void onError(int code, String message) { // TODO Auto-generated method stub } @Override public void onProgress(int progress, String status) { // TODO Auto-generated method stub if (callback != null) { callback.onProgress(progress, status); } } }); }
@Override protected void initHXOptions() { super.initHXOptions(); // you can also get EMChatOptions to set related SDK options EMChatOptions options = EMChatManager.getInstance().getChatOptions(); options.allowChatroomOwnerLeave(getModel().isChatroomOwnerLeaveAllowed()); }
@Override protected void initListener() { super.initListener(); IntentFilter callFilter = new IntentFilter(EMChatManager.getInstance().getIncomingCallBroadcastAction()); if (callReceiver == null) { callReceiver = new CallReceiver(); } // 注册通话广播接收者 appContext.registerReceiver(callReceiver, callFilter); // 注册消息事件监听 initEventListener(); }
/** 手机震动和声音提示 */ public void viberateAndPlayTone(EMMessage message) { if (message != null) { if (EMChatManager.getInstance().isSlientMessage(message)) { return; } } HXSDKModel model = HXSDKHelper.getInstance().getModel(); if (!model.getSettingMsgNotification()) { return; } if (System.currentTimeMillis() - lastNotifiyTime < 1000) { // received new messages within 2 seconds, skip play ringtone return; } try { lastNotifiyTime = System.currentTimeMillis(); // 判断是否处于静音模式 if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) { EMLog.e(TAG, "in slient mode now"); return; } if (model.getSettingMsgVibrate()) { long[] pattern = new long[] {0, 180, 80, 120}; vibrator.vibrate(pattern, -1); } if (model.getSettingMsgSound()) { if (ringtone == null) { Uri notificationUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); ringtone = RingtoneManager.getRingtone(appContext, notificationUri); if (ringtone == null) { EMLog.d(TAG, "cant find ringtone at:" + notificationUri.getPath()); return; } } if (!ringtone.isPlaying()) { String vendor = Build.MANUFACTURER; ringtone.play(); // for samsung S3, we meet a bug that the phone will // continue ringtone without stop // so add below special handler to stop it after 3s if // needed if (vendor != null && vendor.toLowerCase().contains("samsung")) { Thread ctlThread = new Thread() { public void run() { try { Thread.sleep(3000); if (ringtone.isPlaying()) { ringtone.stop(); } } catch (Exception e) { } } }; ctlThread.run(); } } } } catch (Exception e) { e.printStackTrace(); } }