Java Question create an accesivilityService

intera

Member
Licensed User
Longtime User
Here is the info:
B4X:
http://developer.android.com/training/accessibility/service.html

Should I need a library for this?¿?
Actually I tried and create it with this code:
B4X:
package anywheresoftware.b4a.sample;

import anywheresoftware.b4a.BA.ShortName;




import android.accessibilityservice.AccessibilityService;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;

@ShortName("FirstLib")

public class FirstLib extends AccessibilityService {
   
   
    /*
    * Return a log of the AccesibilityService
    */

    private final static String TAG="WhtNotificationService";
    public static final String PACKAGE_NAME = "com.whatsapp";
   
   
    @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {

        Log.d(TAG,"new Event="+event.toString());
       
       
       
       
    }

    @Override
    public void onInterrupt() {
       
    }


   
}

But I think I have no idea what I am doing...
I added to b4a ,dimmed it and a lot of methods appear...?¿?¿And it supposed to just create a log when a notification get in....

Actually it also says to change the manifest like this:

B4X:
<service android:name=".MyAccessibilityService">
    <intent-filter>
        <action android:name="android.accessibilityservice.AccessibilityService" />
    </intent-filter>
    . . .
</service>

It is too late.....

Any help would be really appreciated

Thanks in advanced
 

intera

Member
Licensed User
Longtime User
Erel Thanks for the reply...however, I think now I am even more lost:(

So I will try to explain what I did:

1º)create the lib as explainied before, this lib supposed to just send me a log when a Accessibility Event occurs...(I hope)
2º)change my manifest editor as you suggested but nothing happens
3º)change the manifest editor like this to point to a new Service(in my case by now only want to pick up the whastaspp events,although also include sms received to check if it is working)

B4X:
 'la ccesibilityService de mi libreria:

AddServiceText(WhatasppService,
<service android:name="anywheresoftware.b4a.sample.FirstLib">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data android:name="android.accessibilityservice"
                            android:resource="@xml/accessibilityservice" />

. . .
</service>)

and create a accesibilityservice.xml like this:


B4X:
<?xml version="1.0" encoding="utf-8"?>

<accessibility-service
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:accessibilityEventTypes="typeNotificationStateChanged"
    android:packageNames="com.whatsapp,android.provider.Telephony.SMS_RECEIVED"
    android:accessibilityFeedbackType="feedbackVisual"
    android:notificationTimeout="100"
    android:canRetrieveWindowContent="true"
    />

made it read only and copy to RES/XML...no compiling errors...so I guess it is OK;)

Of course nothing happens on the service::(:(

B4X:
#Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

        Dim AccesibilityServiceMio As FirstLib
       
End Sub
Sub Service_Create
Log("creado WhastasppService")

End Sub

Sub Service_Start (StartingIntent As Intent)

Log("empezado WhastasppService")
End Sub

Sub Service_Destroy

End Sub

And I gues that some how I should do something with my "library" right?
I try to dimmed but the dimmed object have a lot of methods, but none is initalize or something like this....:(

Please any help would be really appreciate!!!


BTW:all the info about the XML content for whastaspp was taken from here:

http://gmariotti.blogspot.com.es/2013/02/how-to-write-dashclock-extension_23.html
 

intera

Member
Licensed User
Longtime User
Thanks for the reply,however for my os obvious that I have no idea at all about making a lib, or about java...:(
already waste a lot of time and nothing, so if some one could port the accesibility service I will really appreciate it
Otherwise I have no choice but to learn Java;)
 

intera

Member
Licensed User
Longtime User
Finally got it working!!!!!;)
Will share it as soon as I translate it to english, and made a explanation guide
 

intera

Member
Licensed User
Longtime User
sorry..long time ago..moved to Java, cant even remember in what project I used it..sorry
 
Top