0

I want to develop an app where I fetch the on screen content of another app, fetch relevant info about the content from the web and display it in my app. For example, if the user is browsing the Amazon app and looking at a product, I would like to fetch info about the product and display a Floating View icon which shall take the user into my app on clicking.

I have gone through several articles and questions here on SO, but am unable to get a head start in any direction. Is there some way to fetch the on screen content of another app ? It would be nice if someone could guide me in the right direction as I feel unsure about where to start. Thanks.

user2125722
  • 1,289
  • 3
  • 18
  • 29
  • The only way I know of to get the on-screen content of another app is with an [`AccessibilityService`](http://developer.android.com/reference/android/accessibilityservice/AccessibilityService.html). I have no idea how that would work with a `WebView`, though. – Mike M. Jan 23 '16 at 05:01
  • @MikeM.I just want to fetch the on screen content of the other app. It doesn't matter if it's unrelated to a WebView. I read we could do it using a WebView, but nonetheless can you tell me more about how to do it using AccessibilityService ? – user2125722 Jan 23 '16 at 05:04
  • should be doable -- broadcast receiver can send data between apps -- https://www.youtube.com/watch?v=LoH3K4wO5q0 -- and in your web app you could scrape HTM Page data by getting the current URL and using a service like YQL to get specific data from any page -- https://developer.yahoo.com/yql/ -- theres some java code ive seen on how to use YQL within an android App -- but search around as theres a few web Page scrapers – Tasos Jan 23 '16 at 05:05
  • @Tasos I guess broadcast receiver can be used to send data from one app to another. The app from which I shall be fetching content could be any app. I want to fetch data from the current screen. – user2125722 Jan 23 '16 at 05:11
  • if i understand you correctly -- you have an app with a webview browsing Amazon. At some point you want to click a button and transfer some data from that Amazon page to another APP?? – Tasos Jan 23 '16 at 05:13
  • @Tasos No I am browsing the official Amazon app or any other shopping app, I want to fetch the on screen content of that app and pass it to my app, which can then fetch things like best price, product info. Hope that makes it clear. Thanks. – user2125722 Jan 23 '16 at 05:16
  • yeah it does. No i dont think you can do that. Only (possibly) with the method in my last comment – Tasos Jan 23 '16 at 05:18
  • [This developer page](http://developer.android.com/training/accessibility/service.html) goes over the basics. Keep in mind, though, that you're pretty much just going to get raw content with no real context, so it's going to take some sly heuristics on your part to decide which content you want to act upon. This won't be a trivial task. – Mike M. Jan 23 '16 at 05:18
  • @MikeM. I found this question. It also tries to achieve a similar thing. But the answers there say it's not possible to get the URL. You can just get the content but not the URL. http://stackoverflow.com/questions/33318083/how-to-get-webview-from-accessibilitynodeinfo – user2125722 Jan 23 '16 at 05:33
  • If the other app is indeed using a WebView, you _might_ be able to get the current URL from an EditText, if one is present for the user to enter a URL, but I don't think you're gonna get the actual page content from the WebView (you might give it a try, though), but your app could download the page source separately. Also, each app is wildly different from the next, so it would take some major effort to interpret any info gleaned from an arbitrary app. – Mike M. Jan 23 '16 at 05:52
  • @MikeM.Most apps use WebView , but don't let the user enter URL. Can I still get the URL in that case from the WebView info (if there is no EditText ,but still WebView is used) ? – user2125722 Jan 23 '16 at 06:11
  • Doubt it. You're not going to be able to call any methods on the WebView, like `getUrl()` or anything. – Mike M. Jan 23 '16 at 06:28

1 Answers1

0

So, the short answer here is that you Can't without root and some good knowhow of reading packets as they go through. Android does have support for linked addresses for apps that hve shown ownership. In this case though, you don't.

The best option is to write your own web browser based on the system browser code or write an extension for one of the web browsers that do.

Chrome has no plans to support extensions

DolphinBrowser Does!

Join the Developer Program here for APIs and Examples

A Dolphin Add-on is an Android application that interacts with the Dolphin browser to create new functionality. An Add-on can interact with web pages or with browser features such as bookmarks, history, and tabs.

childofthehorn
  • 697
  • 1
  • 4
  • 12