woong's
Android 화면 ScreenShot 사용하기 본문
Android 화면 ScreenShot 사용하기
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | package com.iris.util; import android.annotation.SuppressLint; import android.app.Activity; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Point; import android.graphics.Rect; import android.view.Display; import android.view.View; import android.view.WindowManager; public class ScreenshotUtil { public Activity activity; public ScreenshotUtil(Activity activity){ this.activity = activity; } /** * 화면 스크린샷 기능 * @param activity * @return */ @SuppressLint("NewApi") public Bitmap takeScreenShot() { View view = activity.getWindow().getDecorView(); view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap b1 = view.getDrawingCache(); Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); int statusBarHeight = frame.top; Display display = ((WindowManager)activity.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point point = new Point(); display.getSize(point); int height = point.y; int width = point.x; Bitmap b = Bitmap.createBitmap(b1, 0, statusBarHeight, width, height - statusBarHeight); view.destroyDrawingCache(); return b; } } |
'Develop > Android' 카테고리의 다른 글
Android TextView 좌우 반전 하기 (0) | 2016.02.14 |
---|---|
Android Google Chart Option 사용하기 (0) | 2016.02.14 |
Android HalfCircle 사용하기 (0) | 2016.02.14 |
Android Circle Indicator 동적으로 사용하기 (0) | 2016.02.14 |
Slide extend/collapse Animation 사용하기 (0) | 2016.02.14 |
Comments