Get share content through accessibility in android app

浪子不回头ぞ 提交于 2019-12-25 02:58:52

问题


I have an android app, which lets people share content from other apps to it. 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. 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

回答1:


You could try that if it's only for 1 specific app. See question How to click button in settings using 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




回答2:


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. This will reduce number of clicks user has to do.

So,

1) Yes, its possible to get text content via AccessibilityService.

2) No, you cannot automate this action.



来源:https://stackoverflow.com/questions/32919396/get-share-content-through-accessibility-in-android-app

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