This doesn't seem to work at all. 

Android shows the 'user can read things you type' warning
when I enable the Accessibility Service in Android settings, but no 
KeyEvents are received.
At least with a soft (system) keyboard. Anyone tested with a hard keyboard ?
Or have success with soft ?

Thanks,

Pent

Manifest:
<service 
            android:label="Tasker - JB" 
            android:name=".MyAccessibilityService"
            
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/accessibilityservice"
            />
</service>

xml/accessibilityservice:
<accessibility-service 
    xmlns:android="http://schemas.android.com/apk/res/android";
    
android:accessibilityEventTypes="typeViewClicked|typeViewLongClicked|typeWindowStateChanged|typeNotificationStateChanged"
    android:accessibilityFeedbackType="feedbackGeneric"
    android:accessibilityFlags="flagDefault"
    android:canRequestFilterKeyEvents="true"
/>

Set event info:

AccessibilityServiceInfo i = new AccessibilityServiceInfo();
            i.eventTypes = eventFilter;
            i.flags = 
AccessibilityServiceInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS | 
AccessibilityServiceInfo.FLAG_REQUEST_FILTER_KEY_EVENTS | 
AccessibilityServiceInfo.DEFAULT;
            i.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
            i.packageNames = null;

            service.setServiceInfo( i ); 

Various combinations of flags tried of course. Confirmed that the info is 
being set via log.

Receiving events:

@Override
public boolean onKeyEvent( KeyEvent event ) {
        Log.d( TAG, "got one" );
        return true;
 }

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to