cn.jpush.im.android.api.event.LoginStateChangeEvent Java Examples
The following examples show how to use
cn.jpush.im.android.api.event.LoginStateChangeEvent.
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: JmessageFlutterPlugin.java From jmessage-flutter-plugin with MIT License | 5 votes |
/** * 用户登录状态变更事件。 * * @param event 用户登录状态变更事件。 */ public void onEventMainThread(LoginStateChangeEvent event) throws JSONException { HashMap json = new HashMap(); json.put("type", event.getReason().toString()); JmessageFlutterPlugin.instance.channel.invokeMethod("onLoginStateChanged", json); }
Example #2
Source File: BaseActivity.java From Android-IM with Apache License 2.0 | 5 votes |
public void onEventMainThread(LoginStateChangeEvent event) { final LoginStateChangeEvent.Reason reason = event.getReason(); if (reason==user_logout) { showLongToast(this, "该账号在其他设备登录,被强制下线"); JMessageClient.logout(); helper.setUserPW(""); helper.setNakeName(""); Intent intent = new Intent(this, LoginActivity.class); startActivity(intent); } }
Example #3
Source File: BaseActivity.java From jmessage-android-uikit with MIT License | 4 votes |
/** * 接收登录状态相关事件:登出事件,修改密码事件及被删除事件 * @param event 登录状态相关事件 */ public void onEventMainThread(LoginStateChangeEvent event) { LoginStateChangeEvent.Reason reason = event.getReason(); myInfo = event.getMyInfo(); if (null != myInfo) { String path; File avatar = myInfo.getAvatarFile(); if (avatar != null && avatar.exists()) { path = avatar.getAbsolutePath(); } else { path = FileHelper.getUserAvatarPath(myInfo.getUserName()); } Log.i(TAG, "userName " + myInfo.getUserName()); SharePreferenceManager.setCachedUsername(myInfo.getUserName()); SharePreferenceManager.setCachedAvatarPath(path); JMessageClient.logout(); } switch (reason) { case user_password_change: // String title = IdHelper.getString(mContext, "change_password"); // String msg = mContext.getString(R.string.change_password_message); // dialog = DialogCreator.createBaseCustomDialog(mContext, title, msg, onClickListener); break; case user_logout: String title = mContext.getString(IdHelper.getString(mContext, "jmui_user_logout_dialog_title")); String msg = mContext.getString(IdHelper.getString(mContext, "jmui_user_logout_dialog_message")); dialog = DialogCreator.createBaseCustomDialog(mContext, title, msg, onClickListener); break; case user_deleted: View.OnClickListener listener = new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); Intent intent = new Intent(); intent.setClass(BaseActivity.this, DemoActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); BaseActivity.this.finish(); } }; title = mContext.getString(IdHelper.getString(mContext, "jmui_user_logout_dialog_title")); msg = mContext.getString(IdHelper.getString(mContext, "jmui_user_delete_hint_message")); dialog = DialogCreator.createBaseCustomDialog(mContext, title, msg, listener); break; } dialog.getWindow().setLayout((int) (0.8 * mWidth), WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); }