title: screenshot java code in appium selenium
body: <p>Can anyone advice me what should be the screenshot capture code for AndroidDriver. I am using below code for which i am getting Java null pointer exception for the highlighted line.</p>
  
  <p>Driver is a AndroidDriver  driver; which is extended to this class.</p>
  
  <pre><code>public void onTestFailure(ITestResult result) {
      // TODO Auto-generated method stub
  
  
      if(!result.isSuccess()){
          Calendar calendar = Calendar.getInstance();
          SimpleDateFormat formater = new SimpleDateFormat("dd_MM_yyyy_hh_mm_ss");
  
          String methodName = result.getName();
  
  
          ****File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);****
          try {
              String reportDirectory = new File(System.getProperty("user.dir")).getAbsolutePath() + "\\src\\test\\java\\com\\automation\\mobile\\app\\android\\";
              File destFile = new File((String) reportDirectory + "/failure_screenshots/" + methodName + "_" + formater.format(calendar.getTime()) + ".png");
  
              FileUtils.copyFile(scrFile, destFile);
  
              Reporter.log("&lt;a href='" + destFile.getAbsolutePath() + "'&gt; &lt;img src='" + destFile.getAbsolutePath() + "' height='100' width='100'/&gt; &lt;/a&gt;");
  
          } catch (IOException e) {
              e.printStackTrace();
          }
      }
  }
  </code></pre>