'Accessibility service ongesture and window _state_changed not working
I want to get notified when a app open and I want to perform a task on swipe event
The onKeyEvent() method is working perfectly but others not working
I have written this but swipe gesture and toast is not working when I open a app
public class ass extends AccessibilityService {
@Override
protected void onServiceConnected() {
super.onServiceConnected();
}
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
if (event.getPackageName() != null && event.getClassName() != null) {
ComponentName componentName = new ComponentName(
event.getPackageName().toString(),
event.getClassName().toString()
);
ActivityInfo activityInfo = tryGetActivity(componentName);
Toast.makeText(getApplication(), "Currenly "+componentName.flattenToShortString(), Toast.LENGTH_SHORT).show();
boolean isActivity = activityInfo != null;
if (isActivity){
}
}
}
}
private ActivityInfo tryGetActivity(ComponentName componentName) {
try {
return getPackageManager().getActivityInfo(componentName, 0);
} catch (PackageManager.NameNotFoundException e) {
return null;
}
}
@Override
protected boolean onGesture(int gestureId) {
if(gestureId==GESTURE_SWIPE_LEFT_AND_DOWN){
a.vv(); return true;
}else{return false;}
}}`
Here is the XML
<accessibility-servicexmlns:android="http://schemas.android.com/apk/res/android"
android:packageNames=""
android:accessibilityEventTypes="typeAllMask|typeWindowStateChanged"
android:accessibilityFlags="flagRequestFilterKeyEvents|flagIncludeNotImportantViews|flagReportViewIds"
android:description="@string/des"
android:canRetrieveWindowContent="true"
android:canRequestTouchExplorationMode="true"
android:accessibilityFeedbackType="feedbackSpoken"
android:notificationTimeout="100"
android:canPerformGestures="true"
android:canRequestFilterKeyEvents="true"
android:settingsActivity="fool.r.ass"
/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
