/*** Get and save the current screen */private void GetandSaveCurrentImage () {// 1. construct Bitmap WindowManager windowManager = getWindowManager (); Display display = windowManager. getdefadisplay display (); int w = display. getWidth (); int h = display. getHeight (); Bitmap Bmp = Bitmap. createBitmap (w, h, Config. ARGB_8888); // 2. obtain the screen View decorview = this. getWindow (). getDecorView (); decorview. setDrawingCacheEnabled (true); Bmp = dec Orview. getDrawingCache (); String SavePath = getSDCardPath () + "/AndyDemo/ScreenImage"; // 3. save Bitmap try {File path = new File (SavePath); // File String filepath = SavePath + "/Screen_1.png"; file File = new File (filepath); if (! Path. exists () {path. mkdirs ();} if (! File. exists () {file. createNewFile ();} FileOutputStream fos = null; fos = new FileOutputStream (file); if (null! = Fos) {Bmp. compress (Bitmap. compressFormat. PNG, 90, fos); fos. flush (); fos. close (); Toast. makeText (circle1_activity. this, "The screenshot file has been saved to SDCard/AndyDemo/ScreenImage/", Toast. LENGTH_LONG ). show () ;}} catch (Exception e) {e. printStackTrace () ;}}/*** get SDCard directory path function * @ return */private String getSDCardPath () {File sdcardDir = null; // determine whether the SDCard has boolean sdcardExist = Environment. getExternalStorageState (). equals (android. OS. environment. MEDIA_MOUNTED); if (sdcardExist) {sdcardDir = Environment. getExternalStorageDirectory ();} return sdcardDir. toString ();}