Android下免Root权限截屏

2015-03-19 0 590
Android下免Root权限截屏
       /**
	 * 返回的 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;
	}

遇见资源网 java Android下免Root权限截屏 http://www.ox520.com/9011.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务