Reputation: 21
The autofill framework is available in Android 8.0 (API level 26) and higher (See Autofill Framework
Since I want my application to run on older devices as well, I tried implementing it using the GET_ACCOUNTS Manifest permission but this makes the user accept the permission for accessing the Contacts too!
Is there any better way to implement autofill functionality for Android devices running below API level 22?
Upvotes: 0
Views: 60
Reputation: 21
For lower Android versions i.e.below Android 8, you can use Accessibility Service to implement Autofill functionality. See how to create your own Accessibility service https://developer.android.com/guide/topics/ui/accessibility/service
You must register the required events like ypeViewClicked|typeViewFocused|typeViewTextChanged and you'll be notified whenever any of these events is triggered by the OS.By using accessibility service, you can write whatever you want to execute, you have full control over the present screen.
You can read the accessibility tree and identify the field types - username or password etc. You can show a popup using window manager that shows the credentials suggestions list, user can select one and you can write the same in the selected field through accessibility power.
Upvotes: 0