私はWhatsappのアクセシビリティサービスに取り組んでいます。私はTest User
アクセシビリティサービスの現在のWhatsappウィンドウのタイトルバーの名前を取得するにはどうすればよいですか?
ここでは、その文字列を得ることに興味を持って
:ユーザーが入力ボックスを押すたびに、私は通常のWhatsAppグループの受信者のWhatsAppユーザーまたは名前を持つ現在のタイトルバーを知りたいです私のxmlです:ここでは
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeViewClicked|typeViewFocused"
android:packageNames="com.whatsapp"
android:accessibilityFeedbackType="feedbackSpoken"
android:notificationTimeout="100"
android:settingsActivity="com.example.android.apis.accessibility.TestBackActivity"
android:canRetrieveWindowContent="true" />
は私のコードです:
public void onAccessibilityEvent(AccessibilityEvent event) {
final int eventType = event.getEventType();
String eventText = null;
switch(eventType) {
case AccessibilityEvent.TYPE_VIEW_CLICKED:
eventText = "Clicked: ";
break;
case AccessibilityEvent.TYPE_VIEW_FOCUSED:
eventText = "Focused: ";
break;
}
eventText = eventText + event.getContentDescription();
Log.d(TAG, "onAccessibilityEvent: " + eventText);
if (eventText.toLowerCase().contains("type a message")) {
// access the title bar name/string here
}
}
私は現在のウィンドウまたは親ウィンドウを取得し、そのタイトルをチェックしてみました
、両方がnullのように見える:
AccessibilityNodeInfo currentNode = event.getSource();
AccessibilityNodeInfo parentNode = nodeInfo.getParent();
AccessibilityWindowInfo currentWindow = currentNode.getWindow();
AccessibilityWindowInfo parentWindow = parentNode.getWindow();
// currentWindow.getTitle();
// parentWindow.getTitle();
私はあなたがあなたのライブラリにリンクするのを忘れたと思います – avi