2012-03-30 50 views

回答

1

我發現瞭如何以不同的方式做到這一點:

時,它的創建這樣我設置在服務這個服務的設置:

/** 
* Set the info/data for this accessibility service. 
*/ 
public void setServiceInfo(){ 
    AccessibilityServiceInfo accessibilityServiceInfo = new AccessibilityServiceInfo(); 
    //We only want notification event types. 
    accessibilityServiceInfo.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; 
    //We want to provide specific type of feedback. 
    accessibilityServiceInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; 
    //We want to receive events in a certain interval. 
    accessibilityServiceInfo.notificationTimeout = 100; 
    accessibilityServiceInfo.packageNames = null; 
    super.setServiceInfo(accessibilityServiceInfo); 
} 

基本上,我一直在尋找一種方式來實時更新「packageNames」屬性以過濾此服務將響應的包。我無法確定這是否可行,因此我將此屬性設置爲null,然後根據發送到此服務的事件過濾這些包。我實時檢查事件包與我的包數據庫進行響應。我希望別人認爲這有幫助。

相關問題