欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

Android下免Root权限截屏,androidroot, /**

来源: javaer 分享于  点击 5134 次 点评:68

Android下免Root权限截屏,androidroot, /**


       /**     * 返回的 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;    }
相关栏目:

用户点评