package io.appium.android.bootstrap.handler;

import io.appium.android.bootstrap.AndroidCommand;
import io.appium.android.bootstrap.AndroidCommandResult;
import io.appium.android.bootstrap.CommandHandler;

import java.io.File;

import com.android.uiautomator.core.UiDevice;

/**
 * This handler is used to TakeScreenshot.
 * 
 */
public class TakeScreenshot extends CommandHandler {

  /*
   * @param command The {@link AndroidCommand} used for this handler.
   * 
   * @return {@link AndroidCommandResult}
   * 
   * @throws JSONException
   * 
   * @see io.appium.android.bootstrap.CommandHandler#execute(io.appium.android.
   * bootstrap.AndroidCommand)
   */
  @Override
  public AndroidCommandResult execute(final AndroidCommand command) {
    final File screenshot = new File("/data/local/tmp/screenshot.png");
    screenshot.mkdirs();
    final boolean result = UiDevice.getInstance().takeScreenshot(screenshot);
    return getSuccessResult(result);
  }
}
@@ -810,16 +810,29 @@
 .png%22);%0A
+%0A    try %7B%0A  
     scre
@@ -842,44 +842,143 @@
 hot.
-mkdirs();%0A    final boolean result =
+getParentFile().mkdirs();%0A    %7D catch (final Exception e) %7B%0A    %7D%0A%0A    if (screenshot.exists()) %7B%0A      screenshot.delete();%0A    %7D%0A%0A   
  UiD
@@ -1057,14 +1057,27 @@
 ult(
-result
+screenshot.exists()
 );%0A 

Fix screenshot