the java code as below:
and build into jar file OK.
then used in B4A service.
and got errors:
error in: ba.raiseEvent(this,eventName + "_accessibilityevent", "test");
i appreciate your help.
B4X:
package com.sample;
import android.accessibilityservice.AccessibilityService;
import android.view.accessibility.AccessibilityEvent;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.Events;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
@ShortName("ASB")
@Version(1.0f)
@Events(values={"accessibilityevent (event As string)"})
public class ASBWrapper extends AccessibilityService{
BA ba;
String eventName;
AccessibilityService as;
public void Initialize(BA ba, String EventName) {
this.ba = ba;
this.eventName = EventName.toLowerCase(BA.cul);
}
@Override
public void onAccessibilityEvent(AccessibilityEvent arg0) {
// TODO Auto-generated method stub
BA.Log("access");
ba.raiseEvent(this,eventName + "_accessibilityevent", "test");
}
@Override
public void onInterrupt() {
// TODO Auto-generated method stub
BA.Log("interrupt");
}
}
and build into jar file OK.
then used in B4A 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 asb As ASB
End Sub
Sub Service_Create
asb.Initialize("asb")
End Sub
Sub Service_Start (StartingIntent As Intent)
End Sub
Sub asb_AccessibilityEvent(event As String)
Log(event)
End Sub
Sub Service_Destroy
End Sub
and got errors:
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (mm) Create ***
** Service (mm) Start **
** Activity (main) Pause, UserClosed = false **
access
java.lang.NullPointerException
at com.sample.ASBWrapper.onAccessibilityEvent(ASBWrapper.java:34)
at android.accessibilityservice.AccessibilityService$1.onAccessibilityEvent(AccessibilityService.java:518)
at android.accessibilityservice.AccessibilityService$IAccessibilityServiceClientWrapper.executeMessage(AccessibilityService.java:584)
at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4960)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
at dalvik.system.NativeStart.main(Native Method)
error in: ba.raiseEvent(this,eventName + "_accessibilityevent", "test");
i appreciate your help.
Last edited: