Hi all,
I'm trying to catch notifications of other apps in my project (like 'floating notifications'
playstore Link: https://play.google.com/store/apps/details?id=robj.floating.notifications
compiled a java/B4A-library successfull with snippets from Stackoverflow:
java code:
created an accessibilitymetadata.xml file:
XML:
I want to use a service, so I defined the following in manifest.xml:
I can add the coompiled ba4Lib to my Project and can see the voids.
I see now my app under system settings -> accessibility.
and can activate my app...
But I have now idea, how I can initialize / use the lib in my project?
- making a wrapper?
- bind otherwise ?
If somebody could help here please?
thanx and regards
bitstra
I'm trying to catch notifications of other apps in my project (like 'floating notifications'
playstore Link: https://play.google.com/store/apps/details?id=robj.floating.notifications
compiled a java/B4A-library successfull with snippets from Stackoverflow:
java code:
B4X:
package de.esolutions4you.bubblelauncher.notificationservice;
import anywheresoftware.b4a.BA.Author;
import anywheresoftware.b4a.BA.Permissions;
import anywheresoftware.b4a.BA.ShortName;
import anywheresoftware.b4a.BA.Version;
import anywheresoftware.b4a.BA;
import android.accessibilityservice.AccessibilityService;
import android.accessibilityservice.AccessibilityServiceInfo;
import android.view.accessibility.AccessibilityEvent;
@Version(1.6f)
//@Permissions(values={"android.permission.INTERNET"})
@ShortName("NotificationService")
@Permissions(values = {"android.permission.BIND_ACCESSIBILITY_SERVICE"})
//@DependsOn(values={"some java library "})
//@ActivityObject
public class NotificationService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
System.out.println("onAccessibilityEvent");
if (event.getEventType() == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
System.out.println("notification: " + event.getText());
}
}
@Override
protected void onServiceConnected() {
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED;
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_ALL_MASK;
info.notificationTimeout = 100;
setServiceInfo(info);
}
@Override
public void onInterrupt() {
System.out.println("onInterrupt");
}
}
created an accessibilitymetadata.xml file:
XML:
B4X:
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://Schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeNotificationStateChanged"
android:accessibilityFeedbackType="feedbackAllMask"
android:notificationTimeout="100" />
I want to use a service, so I defined the following in manifest.xml:
B4X:
<service
android:name=".notificationservice"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" >
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibilitymetadata" />
</service>
I can add the coompiled ba4Lib to my Project and can see the voids.
I see now my app under system settings -> accessibility.
and can activate my app...
But I have now idea, how I can initialize / use the lib in my project?
- making a wrapper?
- bind otherwise ?
If somebody could help here please?
thanx and regards
bitstra
Last edited: