码迷,mamicode.com
首页 > 移动开发 > 详细

Android下免Root权限截屏

时间:2015-03-03 09:57:47      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:免root权限   android截屏   




       /**
	 * 返回的 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权限截屏

标签:免root权限   android截屏   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!