开发者

About android,how to use the AccessibilityService

hello every one i am trying to use AccessibilityService.but it not work.can somebody help me to point my mistake? thanks.

MyAccessibilityService.java

 public class MyAccessbilityService extends AccessibilityService {

 @Override
    public void onAccessibilityEvent(AccessibilityEvent event) {
    // TODO Auto-generated method stub
      switch(event.getEventType()){
        case AccessibilityEvent.TYPE_VIEW_CLICKED:
          Toast.makeText(getApplicationContext(),"Click", Toast.LENGTH_SHORT).show();
          break;

        case AccessibilityEvent.TYPE_VIEW_LONG_CLICKED:
          Toast.makeText(getApplicationContext(),"Long click", Toast.LENGTH_SHORT).show();
          break;

        case AccessibilityEvent.TYPE_VIEW_FOCUSED:
           Toast.makeText(getApplicationContext(),"Focuse change", Toast.LENGTH_SHORT).show();
           break;

        case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
           Toast.makeText(getApplication开发者_如何学CContext(),"Text change", Toast.LENGTH_SHORT).show();
           break;
         }
       }

         @Override
         public void onInterrupt() {
          // TODO Auto-generated method stub
         }

         @Override
         protected void onServiceConnected() {
          // TODO Auto-generated method stub
          super.onServiceConnected();
          AccessibilityServiceInfo info = new AccessibilityServiceInfo();
          info.feedbackType = AccessibilityServiceInfo.DEFAULT;
          setServiceInfo(info);
         }
        }

the mainfest.xml like this


The AccessibilityServiceInfo.DEFAULT should be applied to info.flags. And the info.feedbackType should be FEEDBACK_xxxxx.

If you are interested in any feedback types, you should specify FEEDBACK_GENERIC.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜