简体   繁体   English

通过Android应用中的辅助功能获取共享内容

[英]Get share content through accessibility in android app

I have an android app, which lets people share content from other apps to it. 我有一个android应用,可让人们从其他应用共享内容。 When it receives the shared data, it looks for the URL in the shared text and fetches the page and does processing on the data fetched. 当它接收到共享数据时,它将在共享文本中查找URL并获取页面,并对获取的数据进行处理。 This is designed with specific purpose and not a generic for all apps. 这是为特定目的而设计的,而不是针对所有应用程序通用的。

It works fine, except that people have to click the share icon and then choose our app name. 效果很好,只是人们必须单击共享图标,然后选择我们的应用程序名称。 With accessibility we can reduce this work for the users. 通过可访问性,我们可以减少用户的工作量。 We are able to get the text displayed in the app. 我们能够在应用程序中显示文本。

  1. Is it possible to get the content which we would get if we were to click the share button. 如果单击共享按钮,是否可以获得我们将获得的内容。 Or 要么
  2. Is it possible to trigger the share button and choose our app without disturbing the user in anyway 是否有可能触发共享按钮并选择我们的应用程序而无论如何都不会打扰用户

You could try that if it's only for 1 specific app. 如果仅适用于1个特定应用,则可以尝试。 See question How to click button in settings using AccessibilityService? 请参阅问题如何使用AccessibilityService单击设置中的按钮? which clicks a button. 单击一个按钮。 This will not scale if you want to do this for more apps. 如果您想对更多应用执行此操作,则无法缩放。 You could however parse the text that is on the screen and look for http links and process them in a background service and then show a floating button like Link Bubble Browser 但是,您可以解析屏幕上的文本,查找http链接并在后台服务中对其进行处理,然后显示一个浮动按钮(如“ 链接气泡浏览器”)

You can simply trigger the share activity of your app when you detect the text from the other app; 当您检测到来自另一个应用程序的文本时,您可以简单地触发您的应用程序的共享活动; but the question is how will you know when user is done typing the text?! 但是问题是,用户输入文字后,您怎么知道?

One way is you can place a system-wide floating button similar to Facebook Messenger and after user clicks it, the text can be shared. 一种方法是,您可以放置​​一个类似于Facebook Messenger的系统范围的浮动按钮,并且在用户单击它之后可以共享文本。 This will reduce number of clicks user has to do. 这将减少用户要做的点击次数。

So, 所以,

1) Yes, its possible to get text content via AccessibilityService. 1)是的,可以通过AccessibilityService获取文本内容。

2) No, you cannot automate this action. 2)不,您不能自动执行此操作。

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

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