1

Basically i want to create an android SDK where it want to get all the information about the host app 's content or the current screen's UI widget like textview, imageview, webview, recyclerview...etc.which is seen by the user.The purpose of this informations is to make ads on basis of the app info.

I've already have an idea of doing this with the help of the app's rootview and traversing its childview for getting its data but is this only way to achieve this? because i don't think this as an efficient way to proceed.Please let me know the elegant approach

sohan shetty
  • 289
  • 1
  • 16

1 Answers1

1

Such screen info gathering can be achieved by using an Accessibility Service https://developer.android.com/guide/topics/ui/accessibility/service

Accessibility permission requires user consent though as it a dangerous permission.

Ranzz
  • 396
  • 3
  • 10
  • The above link from the accessibility service is it really helpful in getting the app's current screen UI widget like textview, imageview, recyclerview..etc ???. – sohan shetty Jan 22 '21 at 18:03
  • Actually the above link was not helpful in my scenario.It is for the users with disable.But wat i need is not this, all i was looking for the android SDK that will be helpful in gathering or extracting data about the current screen's widget present in the xml on the host app for ex if screen A has textview and imageview then i need the value of that textview and imagview .that data will be used later for analytics and ads purpose to target the users. – sohan shetty Jan 24 '21 at 18:17
  • You are right, accessibility service is primarily meant for users with disability, but from a developer perspective, it can be used to read the app UI. There is a class named AccessibilityNodeInfo, which holds this information. Check out this answer: https://stackoverflow.com/questions/43834499/how-to-get-view-id-using-accessibility-service-in-android – Ranzz Jan 25 '21 at 04:26
  • Its working as expected but the only concern here is to ask permission from the user so is there anything that can be achieved the same behaviour like accessibility service but without asking user permission? – sohan shetty Jan 28 '21 at 14:15
  • is there anything without user permission? – sohan shetty Jan 29 '21 at 13:11
  • I can think of 2 ways: 1) If the host app passes an object of the root view as a parameter to one of your SDK public methods. Then you can get access to all the child views using this object. 2) The accessibility service permission android.permission.BIND_ACCESSIBILITY_SERVICE has protectionLevel "signature". So you can get this permission without user consent only if the host app is signed with the platform keys of the the manufacturer. – Ranzz Jan 29 '21 at 13:35