中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Android截屏代碼

2018-07-20    來(lái)源:open-open

容器云強(qiáng)勢(shì)上線!快速搭建集群,上萬(wàn)Linux鏡像隨意使用
 public class MainActivity extends Activity {
 Button mButton;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        mButton = (Button) findViewById(R.id.button);
        mButton.setOnClickListener(new View.OnClickListener() {
         @Override
           public void onClick(View v) {
             GetandSaveCurrentImage();
          }
        });
    }
 protected void GetandSaveCurrentImage() {
      WindowManager widowManager = getWindowManager();
      Display display = widowManager.getDefaultDisplay();
      int w = display.getWidth();
      int h = display.getHeight();
   
      Bitmap Bmp = Bitmap.createBitmap(w,h,Config.ARGB_8888);
      View decorview = this.getWindow().getDecorView();
      decorview.setDrawingCacheEnabled(true);
      Bmp = decorview.getDrawingCache();
  try {
      String SavePath = getSDCardPath() + "/ScreenImage";
      File path = new File(SavePath);
      String filepath = SavePath + "/Screen_1.jpg";
      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();
         Log.i("LW", "截屏文件已保存至SDCard/ScreenImage/下");
       }
  } catch (Exception e) {
       e.printStackTrace();
  }
 }
 private String getSDCardPath() {
  File sdCardDir = null;
  boolean sdcardExit = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
  if(sdcardExit){
   sdCardDir = Environment.getExternalStorageDirectory();
  }
  return sdCardDir.toString();
 }
}

標(biāo)簽: isp

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請(qǐng)與原作者聯(lián)系。

上一篇:php 利用cookie記錄訪問(wèn)次數(shù)

下一篇:php讀取cookie示例代碼