I am using these codes to run a screencap feature on my android app, it is able to capture the screencap and convert it into a bitmap to be used, however after running it a few times. the app becomes slower and I have no idea why
Is it caused by these codes running continuous and leaving processes in the memory? And if so how do I properly close them?
Process process = Runtime.getRuntime().exec("su");
OutputStreamWriter outputStream = new OutputStreamWriter(process.getOutputStream());
outputStream.write("/system/bin/screencap -p\n");
outputStream.flush();
Bitmap screen = BitmapFactory.decodeStream(process.getInputStream());
outputStream.write("exit\n");
outputStream.flush();
outputStream.close();