Java Code Examples for

Following code examples demonstrate how to use android. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use various code implementation of this class.


    public static void checkDeviceConnectivity(ITestDevice device, ITestInvocationListener listener,
            String tag) throws DeviceNotAvailableException {
        if (!checkDeviceConnectivity(device)) {
            CLog.w("Connectivity: check failed.");
            InputStreamSource bugSource = device.getBugreport();
            listener.testLog(String.format("bugreport-connectivity-%s", tag),
                    LogDataType.TEXT, bugSource);

    private boolean isFrontActivityLauncher(ITestDevice device) throws DeviceNotAvailableException {
        String output =
                        "dumpsys window windows | grep -E 'mCurrentFocus|mFocusedApp'");
        CLog.d("dumpsys window windows: %s", output);
        if (output.contains("Launcher")) {
            return true;
        } else {
            InputStreamSource screen = device.getScreenshot("JPEG");
            try {
                mLogger.testLog("status_checker_front_activity", LogDataType.JPEG, screen);
            } finally {
            return false;

This interface basically wraps an InputStream to make it clonable.

It should be expected

that a resource will be leaked unless #cancel() is called, and that once #cancel() is called on an instance, that that instance and any InputStreams it has created will be invalid.

Read More