私はそれを試して、whatsapp呼び出しボタンをクリックし、終了ボタンのクリックアクションを呼び出すことができました。以下、私はトーストメッセージ、我々はなりドロウアブルためのトリックを示した上記のコードでAndroid Developers website
public class MyAccessibilityService extends AccessibilityService {
@Override
protected void onServiceConnected() {
AccessibilityServiceInfo info = new AccessibilityServiceInfo();
// Set the type of events that this service wants to listen to. Others
// won't be passed to this service.
info.eventTypes = AccessibilityEvent.TYPE_VIEW_CLICKED |
AccessibilityEvent.TYPE_VIEW_FOCUSED;
// If you only want this service to work with specific applications, set their
// package names here. Otherwise, when the service is activated, it will listen
// to events from all applications.
info.packageNames = new String[]
{"com.whatsapp","com.android.calendar"};
// Set the type of feedback your service will provide.
info.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
// Default services are invoked only if no package-specific ones are present
// for the type of AccessibilityEvent generated. This service *is*
// application-specific, so the flag isn't necessary. If this was a
// general-purpose service, it would be worth considering setting the
// DEFAULT flag.
// info.flags = AccessibilityServiceInfo.DEFAULT;
info.notificationTimeout = 100;
this.setServiceInfo(info);
}
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
final int eventType = event.getEventType();
String eventText = null;
switch(eventType) {
case AccessibilityEvent.TYPE_VIEW_CLICKED:
eventText = "Focused: ";
break;
case AccessibilityEvent.TYPE_VIEW_FOCUSED:
eventText = "Focused: ";
break;
}
//eventText = eventText + event.getContentDescription();
// Do something nifty with this text, like speak the composed string
// back to the user.
Toast.makeText(getApplicationContext(),""+eventText +" --- "+event.getContentDescription(),Toast.LENGTH_LONG).show();
}
@Override
public void onInterrupt() {
}
}
にIを使用しないと、それはもはや異なる例より入手可能な単純なAccessibilityServiceであります「Talkback」アクセシビリティモードでシステムが使用できるcontentDescriptionを提供する。お役に立てれば!!!
いわゆる行動に携わったときのUIの振る舞いについて、あなたは何を確認しましたか? – JoxTraex
私は、アクセシビリティサービスを使ってWhatsappから特定のテキストをキャッチしようとしましたが、Callボタンはテキストではなく描画可能です。それも問題ですので、whatsapp呼び出しが開始されたときと終了するときに情報を取得する他の方法があれば検索していましたか? –
ユーザがwhatsappのアクションバーでコールアイコンをクリックしたときを知りたいですか? – Dinash