Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

processHideSoftInputOnActivityDestroy里面的window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)会引起卡顿 #1835

Open
Assignees
Labels
@weiyfwork

Description

描述 Bug

听云报了一堆卡顿问题,定位在了processHideSoftInputOnActivityDestroy里面的window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN)

  • AndroidUtilCode 的版本:1.31.1
  • 出现 Bug 的设备型号:小米 Redmi 50等一系列小米手机 见后面的截图
  • 设备的 Android 版本:Android 12 到 Android 15都有 见后面的截图

相关代码

以下代码中的:window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

private void processHideSoftInputOnActivityDestroy(final Activity activity, boolean isSave) {
 try {
 if (isSave) {
 Window window = activity.getWindow();
 final WindowManager.LayoutParams attrs = window.getAttributes();
 final int softInputMode = attrs.softInputMode;
 window.getDecorView().setTag(-123, softInputMode);
 window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
 } else {
 final Object tag = activity.getWindow().getDecorView().getTag(-123);
 if (!(tag instanceof Integer)) return;
 UtilsBridge.runOnUiThreadDelayed(new Runnable() {
 @Override
 public void run() {
 try {
 Window window = activity.getWindow();
 if (window != null) {
 window.setSoftInputMode(((Integer) tag));
 }
 } catch (Exception ignore) {
 }
 }
 }, 100);
 }
 } catch (Exception ignore) {
 }
 }

截图

听云报的卡顿信息
Image
系统分布
Image
手机型号分布
Image

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      AltStyle によって変換されたページ (->オリジナル) /