B4A Library Accessibility Services (assisting users with disabilities, automation etc)

Scotter

Active Member
Licensed User
Did I miss something? When I did that search before (yesterday) and now, I see nothing on Accessibility. The closest match it found was "access". I'd scroll down through the pages of the search results, except... wouldn't posts on accessibility be above posts on access if I searched for accessibility?

EDIT: OK I went ahead and scrolled down to page two and am finding some posts on accessibility (but Moster67's service). I'm leaving this post up so you can hopefully help me understand why the search results arrived sorted this way? I guess it is prioritizing date? But I have "any time" set in the date dropdown. I'm confused, heh.
 

Scotter

Active Member
Licensed User
@Erel

(1) I'm finding no instruction or other info on the included Accessibility library. Why is this? If the info (tutorials or anything) exists, can you please share a direct link?
Thank you!

(2) Do I need it to be a "service" in order to be able to add text to any object that will get read when a blind person has turned on the accessibility features in their settings?
 

Scotter

Active Member
Licensed User
Docs: https://www.b4x.com/android/help/accessibility.html

It shows up fine for me:

View attachment 75402

Anyway, if you want to discuss the B4A Accessibility library, then you should open a separate thread so this thread is not cluttered.
YES! Thank you thank you thank you!
It's all clear now, hehe. Meaning I see I only need the basic accessibility features of focus order and text description.
Woohoo! Maybe some day I'll need the more feature-rich service you provide but for now, I need super simple.
 

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hi Mike

Got this error this morning:

B4X:
java.lang.NullPointerException: Attempt to invoke interface method 'java.lang.String java.lang.CharSequence.toString()' on a null object reference
    at com.tillekesoft.accessibilityservices.AccessibilityEventsListenerWrapper.onAccessibilityEvent(AccessibilityEventsListenerWrapper.java:161)
    at android.accessibilityservice.AccessibilityService$2.onAccessibilityEvent(AccessibilityService.java:1538)
    at android.accessibilityservice.AccessibilityService$IAccessibilityServiceClientWrapper.executeMessage(AccessibilityService.java:1724)
    at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:37)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6863)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:537)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)


This is the first time we have got this, and having been using the lib for a couple of months and it has been quite stable. Any ideas why this would occur ?

Regards

John.
 

moster67

Expert
Licensed User
Longtime User
Yep,
Was already fixed some time ago in a separate project. I will try to update the lib here in the forum in the next days.
 

samperizal

Active Member
Licensed User
Longtime User
Greetings.
I tried running the example on a tablet with Android 4.4.2 and it doesn't work. Is there any limitation of operating system version?
Thank you
 

moster67

Expert
Licensed User
Longtime User
I tried running the example on a tablet with Android 4.4.2 and it doesn't work
Well, the sample project was set to require SDK 21 as a minimum (which you can see if you open the manifest editor). It might work if you reduce the minimum SDK to perhaps 16. I think the methods used in the sample project might go as low as that.

Some of the text related methods in the library itself might require at least SDK 21 if I recall correctly.
In a future update, I may make that clear in the description in the IDE or handle it by code but that really depends on if there is really an interest in this library.
 

moster67

Expert
Licensed User
Longtime User
Yes, I want to take a look at source code, where I can find it ??
Sorry, but I decided to unpublish it a long time ago since I received lots of questions from users asking me to help them with Java issues and how to implement this and that. I simply did not have time to help all considering I also published it for free after a lot of time studying how to get it working properly with B4A. The very reason I wrote the wrapper was so there was no need for Java and to make a generic version available suitable for most tasks.
My wrapper can be customized to be more specific for certain tasks but then you need to contact me as I wrote in the first post.
 

Jannete

Member
Hello, my name is Jannete and i work in a school of people with problems of vision, and i like to use this libary to my app.

Actually i use a tts and voice recognition, but i like add a function called safe number, if the person be lost, they can push a bt button to activate a camera, the camera take a photo from the place and send that in whatsapp to the safe number (with your example i can send only the location, but i like a photo option for more precision).

Thank you, and excuse me for my bad english.
 

moster67

Expert
Licensed User
Longtime User
Hmm, the WhatsApp sample app is just to show what can be achieved using Accessibility Services and automation. The library itself is not focused on WhatsApp - that was just an example.
To resolve your problem I guess you can use the camera, save the picture and send it as an attachment in a WhatsApp message using intents (if available) or maybe you can use the library to simulate a tap on the photo-button in WhatsApp and then send.
 

Jannete

Member

First, thank you for your answer. I think of something similar:
:

B4X:
 Dim out As OutputStream

        out = File.OpenOutput(File.DirRootExternal & "/app/", "image.jpg", False)
        b.WriteToStream(out, 100, "JPEG")
        out.Close
        
        Dim FileName As String = "imge.jpg"
        File.Copy(File.DirRootExternal & "/app/", "image.jpg", Starter.Provider.SharedFolder, FileName)
        Dim in As Intent
        in.Initialize(in.ACTION_SEND, "")
        in.SetType("image/jpg")
        in.PutExtra("android.intent.extra.STREAM", Starter.Provider.GetFileUri(FileName))
        in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
        in.WrapAsIntentChooser("Select")
        StartActivity(in)

My app takes a photo with camera libary, but when i try to send, Whatsapp asks to choice a contact. I cant found the Intent to open a share with contact image dialog.

Maybe as you say, i can simulate the touches, but i cant find the way, i see the SendInput library, but it cannot work within a service.

When i see your example, i cant find how emulate the tap events (i only see the tap for send).

Any help would be greatly appreciated.
 

Jannete

Member
I find this:

B4X:
Action: Click
UI Element Class: android.widget.TextView
Ui Element Text: John Doe
UI Element ID: com.whatsapp:id/conversations_row_contact_name

With intent of share image in whatsapp, i can add some similar to select a contact, but i dont know how to add to the code.
 

JohnC

Expert
Licensed User
Longtime User
Got a question....

In the example, it "clicks" the "Send" button using:
B4X:
success = acs.PerformNodeActionOnViewWithArgs(True, "com.whatsapp:id/send",AccServConstants.ACTION_CLICK, Null)

But how did you figure out the criteria name of "com.whatsapp:id/send" was the proper criteria to use?
 
Last edited:

americo Montes

New Member
Licensed User
Funciona perfectamente.
pero trate de utilizarla para enviar mensajes multiples. ahi lastimosamente no funciona ya que envia el mensaje al primer usuario y nada mas..
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…