Android焦点窗口切换日志

window

在dumpsys window中查看mCurrentFocus和mFocusedApp

mCurrentFocus=Window{f96644 u0 NotificationShade} 
mFocusedApp=ActivityRecord{e9566ee u0 com.android.launcher3/.uioverrides.QuickstepLauncher} t12}

mCurrentFocus指的是当前的焦点窗口

mFocusedApp指的是当前的焦点Activity

input

在dumpsys input中查看FocusedApplications和FocusedWindows

  FocusedApplications:
    displayId=0, name='ActivityRecord{e9566ee u0 com.android.launcher3/.uioverrides.QuickstepLauncher} t12}', dispatchingTimeout=5000ms
  FocusedWindows:
    displayId=0, name='f96644 NotificationShade'

event log

request 和 entering正常情况下是一一对应,打印了entering则表示真正的焦点已经进入到对应的窗

发生Application does not hava focused window时,一般request 有打印,我们可以通过是否有entering的打印来分析

1.entering部分有打印,代表焦点已经在input里面,但是仍然有ANR,就需要从input等方面分析

2.entering部分未打印,代表input没有被触发焦点窗口设置到input,需排查SurfaceFlinger或WMS

焦点切换三部log打印位置

java层InputMonitor.java的requestFocus(); // "Focus request"

native层InputDispatcher.cpp的setFocusedWindow(),binder线程; // "Focus receive"

native层InputDispatcher.cpp的dispatchFocusLocked(),InputDispatcher线程 // "Focus " + ("entering " : "leaving ")

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Android提供了一些默认的窗口切换动画,可以在Activity之间切换时使用,也可以自定义窗口切换动画。以下是几种常用的窗口切换动画: 1. 淡入淡出动画: 在res/anim文件夹下创建两个xml文件:fade_in.xml和fade_out.xml fade_in.xml: ```xml <?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:duration="300" android:fromAlpha="0.0" android:toAlpha="1.0" /> ``` fade_out.xml: ```xml <?xml version="1.0" encoding="utf-8"?> <alpha xmlns:android="http://schemas.android.com/apk/res/android" android:duration="300" android:fromAlpha="1.0" android:toAlpha="0.0" /> ``` 在Activity中使用: ```java Intent intent = new Intent(this, SecondActivity.class); startActivity(intent); overridePendingTransition(R.anim.fade_in, R.anim.fade_out); ``` 2. 滑动动画: 在res/anim文件夹下创建两个xml文件:slide_in_right.xml和slide_out_left.xml slide_in_right.xml: ```xml <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="300" android:fromXDelta="100%" android:toXDelta="0%" /> </set> ``` slide_out_left.xml: ```xml <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <translate android:duration="300" android:fromXDelta="0%" android:toXDelta="-100%" /> </set> ``` 在Activity中使用: ```java Intent intent = new Intent(this, SecondActivity.class); startActivity(intent); overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left); ``` 3. 缩放动画: 在res/anim文件夹下创建两个xml文件:zoom_in.xml和zoom_out.xml zoom_in.xml: ```xml <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:duration="300" android:fromXScale="0.0" android:fromYScale="0.0" android:pivotX="50%" android:pivotY="50%" android:toXScale="1.0" android:toYScale="1.0" /> </set> ``` zoom_out.xml: ```xml <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android"> <scale android:duration="300" android:fromXScale="1.0" android:fromYScale="1.0" android:pivotX="50%" android:pivotY="50%" android:toXScale="0.0" android:toYScale="0.0" /> </set> ``` 在Activity中使用: ```java Intent intent = new Intent(this, SecondActivity.class); startActivity(intent); overridePendingTransition(R.anim.zoom_in, R.anim.zoom_out); ``` 以上是几种常用的窗口切换动画,可以根据需要选择适合的动画效果。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

薛文旺

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值