简体   繁体   English

使用Android中的辅助功能获取应用名称

[英]Get the Name of the App using Accessibility Service in Android

I'm working in Accessibility Service . 我正在使用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. 我已经研究了Android网站开发人员中无障碍服务的文档。 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. 因此,如果有任何方法可以获取应用程序的名称,请提出您的建议。

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. 这可以唯一地标识从其发送给定AccessibilityNodeInfo的应用程序。

You could also consider using this: 您也可以考虑使用此方法:

someAccessibilityService.getRootInActiveWindow();

And crawl down the view hierarchy looking for a title bar. 并向下浏览视图层次结构以查找标题栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM