I'm trying to make a screenshot. Suggested a couple of methods
protected Bitmap MakeScreenshotOfView(View v) { Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.RGB_565); Canvas c = new Canvas(b); v.draw(c); return b; } public static Bitmap getBitmapFromView(View view, int totalHeight, int totalWidth) { Bitmap returnedBitmap = Bitmap.createBitmap(totalWidth,totalHeight , Bitmap.Config.RGB_565); Canvas canvas = new Canvas(returnedBitmap); Drawable bgDrawable = view.getBackground(); if (bgDrawable != null) bgDrawable.draw(canvas); else canvas.drawColor(Color.WHITE); view.measure( View.MeasureSpec.makeMeasureSpec(totalWidth,View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(totalHeight,View.MeasureSpec.EXACTLY)); view.layout(0,0,totalWidth,totalHeight); view.draw(canvas); return returnedBitmap; } Both work on simple screens, where not a lot of View. But I need to make a screen of such a screen:
It is dynamically filled with small imageview. Then comes the animation. At the end of the animation I try to make a screen, he thinks and then gives out OOM.
06-24 18:40:29.700 4166-4186/com.appache.fingerdynamometersimulator I/art: Background sticky concurrent mark sweep GC freed 24(3KB) AllocSpace objects, 0(0B) LOS objects, 0% free, 468MB/468MB, paused 19.281ms total 76.606ms at GCDaemon thread CareAboutPauseTimes 1 06-24 18:40:29.855 4166-4186/com.appache.fingerdynamometersimulator I/art: Background partial concurrent mark sweep GC freed 8(560B) AllocSpace objects, 0(0B) LOS objects, 3% free, 470MB/486MB, paused 20.558ms total 77.170ms at GCDaemon thread CareAboutPauseTimes 1 java.lang.OutOfMemoryError: Failed to allocate a 1704972 byte allocation with 908240 free bytes and 886KB until OOM at dalvik.system.VMRuntime.newNonMovableArray(Native Method) at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:842) at android.graphics.Bitmap.createBitmap(Bitmap.java:812) The first two lines are repeated many times with different values and then crashes. HELP !!!

android:largeHeap="true"attribute to theapplicationtag in the manifest. This is not exactly the right decision, but if it works - the simplest one is Vladyslav MatviienkoProcess p = Runtime.getRuntime().exec(new String[]{"su", "-c", "/system/bin/screencap -p /sdcard/img.png"});- pavel