मैंने कोशिश की और मैं व्हाट्सएप कॉल बटन पर कब्जा करने में सक्षम हूं और एंड बटन बटन पर क्लिक करें। नीचे सरल AccessibilityService है कि मैं का इस्तेमाल किया और यह कोई और अधिक अलग उदाहरण से 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() {
}
}
में उपलब्ध उपरोक्त कोड में मैं एक टोस्ट संदेश और drawable के लिए चाल हम हो जाएगा से पता चला है कंटेंट डिस्क्रिप्शन प्रदान करना जिसे सिस्टम द्वारा "टॉकबैक" एक्सेसिबिलिटी मोड में इस्तेमाल किया जा सकता है। उम्मीद है की यह मदद करेगा!!!
तथाकथित व्यवहार में शामिल होने पर यूआई के व्यवहार के बारे में आपने क्या पुष्टि की है? – JoxTraex
मैंने व्हाट्सएप से विशिष्ट टेक्स्ट को पकड़ने के लिए एक्सेसिबिलिटी सेवा का उपयोग करने का प्रयास किया है, लेकिन कॉल बटन एक ड्रायबल है, पाठ नहीं। यह भी एक समस्या है इसलिए मैं खोज रहा था कि व्हाट्सएप कॉल कब शुरू होता है और जब यह समाप्त होता है तो जानकारी प्राप्त करने का कोई अन्य तरीका है? –
क्या आप जानना चाहते हैं कि उपयोगकर्ता व्हाट्सएप एक्शनबार में कॉल आइकन पर कब क्लिक करता है? – Dinash