This Screenshot function in AndroidStudio works?

0

I'm running this function to try to print the device screen, and save the image to the internal device of the file. But nothing happens.

View v = getWindow().getDecorView().findViewById(R.id.activity_main);
        v.setDrawingCacheEnabled(true);
        Bitmap bitmap = Bitmap.createBitmap(v.getDrawingCache());
        v.setDrawingCacheEnabled(false);
        OutputStream out = null;
        File imageFile = new File("croqui-teste");
        try {
            out = new FileOutputStream(imageFile);
            bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
            out.flush();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
            } catch (Exception exc) {
            }
        }
    
asked by anonymous 12.06.2018 / 14:27

0 answers