surfaceview
SurfaceView flashes black on load
I think I found the reason for the black flash. In my case I’m using a SurfaceView inside a Fragment and dynamically adding this fragment to the activity after some action. The moment when I add the fragment to the activity, the screen flashes black. I checked out grepcode for the SurfaceView source and here’s … Read more
How to capture image from custom CameraView in Android?
try to use Surface View for creating dynamic camera view and set in your required portion. following code try variables set Class level (Global) Button btn_capture; Camera camera1; SurfaceView surfaceView; SurfaceHolder surfaceHolder; public static boolean previewing = false; Following code in onCreate() method getWindow().setFormat(PixelFormat.UNKNOWN); surfaceView = new SurfaceView(this); surfaceHolder = surfaceView.getHolder(); surfaceHolder.addCallback(this); surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); btn_capture = … Read more
Android Take Screenshot of Surface View Shows Black Screen
There is a great deal of confusion about this, and a few correct answers. Here’s the deal: A SurfaceView has two parts, the Surface and the View. The Surface is on a completely separate layer from all of the View UI elements. The getDrawingCache() approach works on the View layer only, so it doesn’t capture … Read more
What can I do when the BufferQueue has been abandoned?
What you’re doing is essentially what’s written in the TextureView docs, so it should work. The error message means that the “producer” side of the BufferQueue (the camera) grabbed a buffer, and is now trying to un-grab it (via cancelBuffer()). However, the “consumer” side (the SurfaceTexture) has gone away. Because the “consumer” side owns the … Read more
How can I set camera preview size to squared aspect ratio in a squared SurfaceView (like Instagram)
As said before you need to find the correct preview size (the one with aspect ratio 1:1) and probably you have to use FrameLayout for the SurfacePreview. It seems that you have and aspect ratio problem maybe you have the right preview size but you are placing it in an incorrect layout. Another solution might … Read more
What’s differences between Surfaceview and TextureView?
TextureView A TextureView can be used to display a content stream. Such a content stream can for instance be a video or an OpenGL scene. Example : https://github.com/dalinaum/TextureViewDemo Document: http://developer.android.com/reference/android/view/TextureView.html SurfaceView Provides a dedicated drawing surface embedded inside of a view hierarchy. Examples : http://www.mindfiresolutions.com/Using-Surface-View-for-Android-1659.php http://blog.wisecells.com/2012/06/04/surface-view-android/ Document: http://developer.android.com/reference/android/view/SurfaceView.html
Moving MapFragment (SurfaceView) causes black background flickering
Of course the proper solution will be for Google to fix the problem (see Android Maps V2 issue 4639: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4639). However, one of my coworkers suggested simply extending the map beyond its container. If we extend the map fragment beyond the visible region of its container, like so: android:layout_marginLeft=”-40dp” android:layout_marginRight=”-40dp” we can reduce/eliminate the flickering. … Read more
How to draw an overlay on a SurfaceView used by Camera on Android?
SurfaceView probably does not work like a regular View in this regard. Instead, do the following: Put your SurfaceView inside of a FrameLayout or RelativeLayout in your layout XML file, since both of those allow stacking of widgets on the Z-axis Move your drawing logic into a separate custom View class Add an instance of … Read more
How SurfaceHolder callbacks are related to Activity lifecycle?
Edit: if the targetSDK is greater than 10, putting the app to sleep calls onPause and onStop. Source I looked at the lifecycle of both the Activity and the SurfaceView in a tiny camera app on my gingerbread phone. You are entirely correct; the surface is not destroyed when the power button is pressed to … Read more