FullScreen快照包括状态栏?

时间:2015-11-06 07:15:42

标签: android

我试图捕捉我的应用程序的屏幕,

public void takeSnap(View v) {
    final View decorView = getWindow().getDecorView().getRootView();
    decorView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_LOW);
    decorView.setDrawingCacheEnabled(true);
    decorView.buildDrawingCache();

    Bitmap img = decorView.getDrawingCache();

    ((ImageView) findViewById(R.id.snap)).setImageBitmap(img);


    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {

            decorView.destroyDrawingCache();
            decorView.setDrawingCacheEnabled(false);
        }
    }, 400);
}

我在这里面临的问题是,它需要快照,但没有状态栏图标可见!我想要状态栏图标

after taking snapshot

1 个答案:

答案 0 :(得分:0)

我认为它基本上是许可问题。 Android使用所谓的 framebuffer 进行视频显示。

framebuffer 文件的权限为rw- rw- ---。注意最后一个"组"有3" - "' s。这基本上意味着如果您不是所有者(也是root用户),您甚至无权读取该文件。

采用该设备完整屏幕截图的应用程序主要是作为系统应用程序。对于所有其他外部应用程序,我们需要一个root用户手机才能抓住整个屏幕。

通过以下链接检查答案:Why do we need a rooted phone for taking screenshots