我正在使用tasker自动发送SMS,我需要检查当前前台应用程序包名称是否为x.如果它是x,那么做别的事情.我尝试使用pgrep,但即使app x在后台,它也会返回pid.有没有办法从shell检查x是否在前景?谢谢
Jar*_*ler 10
这对我有用.请注意,为了使其正常工作,您应该安装busybox并将其mCurrentFocus
作为当前路径上busybox的符号链接:
adb shell dumpsys window windows | grep -E 'mCurrentFocus' | cut -d '/' -f1 | sed 's/.* //g'
Run Code Online (Sandbox Code Playgroud)
com.facebook.katana