首页 > 移动平台 > 详细

Android下免Root权限截屏

时间:2015-03-03 09:55:01      阅读:395      评论:0      收藏:0      [点我收藏+]



       /**
	 * 返回的 bitmap就是屏幕的内容
	 */
	private static Bitmap takeScreenShot(Activity activity) {
		View view = activity.getWindow().getDecorView();
//		Enables or disables the drawing cache
		view.setDrawingCacheEnabled(true);
//		will draw the view in a bitmap
		view.buildDrawingCache();
		Bitmap bitmap = view.getDrawingCache();
		Rect frame = new Rect();
		activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
		int statusBarHeight = frame.top;
		int width = activity.getWindowManager().getDefaultDisplay().getWidth();
		int height = activity.getWindowManager().getDefaultDisplay().getHeight();
		// 去掉标题栏
		Bitmap b = Bitmap.createBitmap(bitmap, 0, statusBarHeight, width,
				height - statusBarHeight);
		view.destroyDrawingCache();
		return b;
	}

Android下免Root权限截屏

原文:http://blog.csdn.net/andywuchuanlong/article/details/44033769

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!