Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java android:如何通过编程获得整个屏幕的截图_Java_Android_Screenshot - Fatal编程技术网

Java android:如何通过编程获得整个屏幕的截图

Java android:如何通过编程获得整个屏幕的截图,java,android,screenshot,Java,Android,Screenshot,下面是截图的代码。。但问题是它只需要应用程序的屏幕截图。。不是整个屏幕(返回和主页按钮和通知栏) 有什么方法可以让我拍摄整个屏幕的截图而不仅仅是应用程序 private void takeScreenshot() { Date now = new Date(); android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now); try { // image namin

下面是截图的代码。。但问题是它只需要应用程序的屏幕截图。。不是整个屏幕(返回和主页按钮和通知栏) 有什么方法可以让我拍摄整个屏幕的截图而不仅仅是应用程序

private void takeScreenshot() {
    Date now = new Date();
    android.text.format.DateFormat.format("yyyy-MM-dd_hh:mm:ss", now);

    try {
        // image naming and path  to include sd card  appending name you choose for file
        String mPath = Environment.getExternalStorageDirectory().toString() + "/" + now + ".jpg";

        // create bitmap screen capture
        View v1 = getWindow().getDecorView().getRootView();
        v1.setDrawingCacheEnabled(true);
        Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
        v1.setDrawingCacheEnabled(false);

        File imageFile = new File(mPath);

        FileOutputStream outputStream = new FileOutputStream(imageFile);
        int quality = 100;
        bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
        outputStream.flush();
        outputStream.close();

      //  openScreenshot(imageFile);
    } catch (Throwable e) {
        // Several error may come out with file handling or DOM
        e.printStackTrace();
    }
} 

你检查过这个了吗看看ImageReader