android.app.UiAutomation.AccessibilityEventFilter Java Examples

The following examples show how to use android.app.UiAutomation.AccessibilityEventFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UiDevice.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
public String waitToast(final String pkg, final long timeout) {
	final StringBuffer result = new StringBuffer();
	final Runnable emptyRunnable = new Runnable() {
		@Override
		public void run() {
		}
	};
	final UiAutomation.AccessibilityEventFilter checkWindowUpdate = (UiAutomation.AccessibilityEventFilter) new UiAutomation.AccessibilityEventFilter() {
		public boolean accept(final AccessibilityEvent event) {
			if (event.getEventType() == 64) {
				final String sourcePackageName = (String) event
						.getPackageName();
				if (sourcePackageName.equals(pkg)) {
					final Parcelable parcelable = event.getParcelableData();
					if (!(parcelable instanceof Notification)) {
						final String toastMsg = (String) event.getText()
								.get(0);
						if (toastMsg != null) {
							result.append(toastMsg);
						}
						return true;
					}
				}
			}
			return false;
		}
	};
	try {
		this.getAutomatorBridge()
				.executeCommandAndWaitForAccessibilityEvent(emptyRunnable,
						checkWindowUpdate, timeout);
	} catch (TimeoutException ex) {
	} catch (Exception ex2) {
	}
	return result.toString();
}
 
Example #2
Source File: UiAutomatorBridge.java    From za-Farmer with MIT License 4 votes vote down vote up
public AccessibilityEvent executeCommandAndWaitForAccessibilityEvent(Runnable command,
        AccessibilityEventFilter filter, long timeoutMillis) throws TimeoutException {
    return mUiAutomation.executeAndWaitForEvent(command,
            filter, timeoutMillis);
}
 
Example #3
Source File: UiAutomatorBridge.java    From JsDroidCmd with Mozilla Public License 2.0 4 votes vote down vote up
public AccessibilityEvent executeCommandAndWaitForAccessibilityEvent(
		Runnable command, AccessibilityEventFilter filter,
		long timeoutMillis) throws TimeoutException {
	return mUiAutomation.executeAndWaitForEvent(command, filter,
			timeoutMillis);
}