Get the Name of the App using Accessibility Service in Android

余生长醉 提交于 2019-12-12 06:21:01

问题


I'm working in Accessibility Service. i need to get the app name using Accessibility Service. i have studied the documentation of the Accessibility Service in developer's of Android website. but there is no mention about getting the app name using Accessibility.

Is this possible to get the name of the application? i think its possible because talk back getting name of the application. So if there is any way to get name of the application, Please give your suggestion.


回答1:


You can't get the "app name" of the application. At least not reliably. The strings that the app reads out are things like the title of the Title Bar, or the string underneath the apps icon. It never actually directly asks the framework for the title of the app it is attached to.

You do, however, have access to the application package.

someAccessibilityNodeInfo.getPackageName();

This uniquely identifies the application that a given AccessibilityNodeInfo was sent from.

You could also consider using this:

someAccessibilityService.getRootInActiveWindow();

And crawl down the view hierarchy looking for a title bar.



来源:https://stackoverflow.com/questions/31112965/get-the-name-of-the-app-using-accessibility-service-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!