title: How to take a screenshots?
body: <p>I am developing an app which is able to take screen shots and I found the following code which allows me to do that </p>
  
  <pre><code>Toast.makeText(this, formattedDate, Toast.LENGTH_SHORT).show();
  Process sh = Runtime.getRuntime().exec("su", null,null);
  OutputStream  os = sh.getOutputStream();
  os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
  os.flush();
  </code></pre>
  
  <p>It saves the image with image name I can change it in code but I want the current date and time as the name. I tried puttinge this: </p>
  
  <pre><code>Calendar c = Calendar.getInstance();
  SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  String formattedDate = df.format(c.getTime());
  </code></pre>
  
  <p>But after putting formattedDate at the place of image it does not work</p>