title: Take a snapshot for current Android Activity?
body: <p>I need in my project to make a snapshot for current activity (whole main layout) in Android, I attempt many ways but always I get error which "<strong>open failed eacces (permission denied) at cretenewFile()</strong>" My code like this: </p>
  
  <pre><code>public void TakeSnapshoot(){
          mainlayout.setDrawingCacheEnabled(true);
          Bitmap b = mainlayout.getDrawingCache();
  
          String extr = Environment.getExternalStorageDirectory().toString()
                  + "/SaveCapture";
         File myPath = new File(extr);
  
          if (!myPath.exists()) {
              boolean result = myPath.mkdir();
              Toast.makeText(this, result + "", Toast.LENGTH_SHORT).show();
          }
          myPath = new File(extr, getString(R.string.app_name) + ".jpg");
  
          Toast.makeText(this, myPath.toString(), Toast.LENGTH_SHORT).show();
          FileOutputStream fos = null;
  
          try {
              fos = new FileOutputStream(myPath);
  
              b.compress(Bitmap.CompressFormat.JPEG, 100, fos);
              fos.flush();
              fos.close();
              MediaStore.Images.Media.insertImage(getContentResolver(), b,
                      "Screen", "screen");
  
  
          } catch (FileNotFoundException e) {
               e.printStackTrace();
              //Log.e("Error", e + "");
          }
  
          catch (Exception e) {
               e.printStackTrace();
              //Log.e("Error", e + "");
          }
  
  }
  </code></pre>
  
  <p>The AndroidManifest:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="SOA.com"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk android:minSdkVersion="8" /&gt;
   &lt;!-- Network State Permissions --&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  &lt;uses-permission android:name="android.permission.RECORD_AUDIO"/&gt;
  &lt;uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/&gt;
   &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  
  &lt;!-- For android different screen sizes --&gt;
      &lt;supports-screens
          android:largeScreens="true"
          android:normalScreens="true"
          android:smallScreens="true"
          android:resizeable="true"
          android:anyDensity="true"
      /&gt; ... 
  </code></pre>
  
  <p>after take a snapshot then I can print what I want!?  I thought this way is best way to print current activity in android?! 
  Please any idea or help will be appreciated !</p>