surfaceview

Camera Preview performance issue on some devices

£可爱£侵袭症+ 提交于 2019-12-12 02:42:38
问题 I am creating a camera application using android camera api by this example: https://examples.javacodegeeks.com/android/core/hardware/camera-hardware/android-camera-example/ I made some changes according to my needs and you can see the code below. The problem is, camera preview for back camera works quite fine on my LG G3 device but on LG G4 it gets too slow. It also works fine with front camera on both devices. What can cause this problem ? CameraPreview: public class CameraPreview extends

Camera preview is completely black after screen off, screen on

丶灬走出姿态 提交于 2019-12-12 02:36:42
问题 I'm working with the CameraPreview in the API Demos that comes with the Android SDK. While the camera preview is running, if I turn off my screen and turn it on again, the camera preview is completely black. The device's camera application somehow manages to restore the camera preview, so there must be a way. Not all devices I've tried exhibit this behavior. I can't confirm, but it seems like the OS version matters. 回答1: You need to release and reacquire the camera in pause/resume. Here's

How to get normal Camera view in Surfaceview android?

橙三吉。 提交于 2019-12-11 23:12:45
问题 Right now, i am doing an sample app where i have to use camera in surfaceview. I have successfully set the camera in surfaceview but i can't get the normal camera view in it, width and height gets changed. Below is my code, i am pleased to get any ideas from anyone. Camera class: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.camera); cameraObject = isCameraAvailiable(); showCamera = new ShowCamera(this, cameraObject); preview

Android: custom draw on an given image (with SurfaceView)

我怕爱的太早我们不能终老 提交于 2019-12-11 21:13:09
问题 I am trying to load an image to SurfaceView, and draw some scratch upon this image. To to that, I have create an custom SurfaceView, MySurfaceView, with the following functions: public MySurfaceView(Context context, AttributeSet attrs) { super(context, attrs); mHolder = getHolder(); mHolder.addCallback(this); mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(3); mPaint.setColor(Color.WHITE); setWillNotDraw(false); } public void setImageBitmap(Bitmap bitmap) { mBitmap = bitmap; }

Android SurfaceView displays blank when locked canvas is not null

感情迁移 提交于 2019-12-11 15:18:33
问题 I'm creating a simple game using a view which extends a SurfaceView and using a thread to draw images on the SurfaceView. The game will have its own thread (game engine) to draw and update drawables. I have 3 classes to achieve this, namely BattleActivity, BattleView, and BattleThread. The BattleActivity is called from another activity. BattleThread will call BattleView.update() and BattleView.render() to do the job. But I don't see anything working. I know it all is reachable through logging

Android virtual display release does not remove display

跟風遠走 提交于 2019-12-11 13:25:00
问题 I am using android Virtual Display along with Projection Manager At certain time, the projection need to be stopped, hence the following actions are taken @Override public void surfaceDestroyed(SurfaceHolder holder) { mMediaProjection.stop(); Log.e(TAG, "mMediaProjection.stopped "); mVirtualDisplay.release(); Log.e(TAG, "virtual display.released "); } The surfaceDestroyed is related to the surface which backs the Virtual Display. When it is the time to start Media Projection again, if

SurfaceView crashes on surfaceChange Android

落花浮王杯 提交于 2019-12-11 12:27:55
问题 I have made an example that extend SurfaceView and Thread to draw some objects on canvas in Android but I'm facing two problems. When press back button the application closed and then show me that "Unfortunately, your example has stopped". When change the orientation from "Portrait" to "Landscape" or VS , the application failed to adjust the new screen and does not update the drawing then it is crash and show the same message "Unfortunately, your example has stopped". Please review code:

Android SurfaceView onTouchEvent not getting called

雨燕双飞 提交于 2019-12-11 11:30:32
问题 I'm developing a game using SurfaceView which listens to touch events. The onTouchEvent method in SurfaceView works fine for many of the devices, but in some devices, sometimes it doesn't get called (Moto X Style is the one) and my app also stops responding. I guess that this might be due to the overloading of main thread due to which onTouchEvent is starving. Could some Android experts over here give me some tips to reduce the load on main thread if it's getting overloaded, or there might be

does onDraw in a surfaceview container causes video to be invalidated?

非 Y 不嫁゛ 提交于 2019-12-11 11:23:34
问题 I have a video view . This view is contained inside a custom FrameLayout called VideoStructure , where I can put also a channel logo or things alike. Under normal conditions, the video is hardware accelerated, so the view is (i suppose) really a transparent "black hole", while the video is decoded & rendered by the relevant hardware. My question is, if I override draw() in the Video View's container (the VideoStructure extends FrameLayout in the image) to draw some stuff (ie. the circle in

Android MediaPlayer on ViewPager blocking UI transition and no callback for initial page loads

坚强是说给别人听的谎言 提交于 2019-12-11 10:01:08
问题 Basically, we want to build a paged horizontal scroll view with one video player on each page; Video should auto-play and auto-pause/stop when page focus is changed. So I decided to use a ViewPager to show video Fragments. Each fragment has its own SurfaceView and MediaPlayer for video playing. The goal is to auto-play video when initial page loads and when user swipes to select a new page. I am facing a few issues: I couldn't get callback from ViewPager when initial page is loaded. I’ve try