surfaceview

Adding text view to surface view

馋奶兔 提交于 2019-12-12 14:53:03
问题 i use this a s surface view in my application and now i want to add text view to this programmatically. How can i do that. "<com.csfcse.udrawer.UdrawerDrawingSurface android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/drawingSurface" android:layout_gravity="left" />" Thanks...... 回答1: An option may be to have a FrameLayout with two children, first the SurfaceView, then whatever you want to overlay on the SurfaceView. In the sample below, the second View in

Camera is null when the surfaceCreated method is executed for second time

爱⌒轻易说出口 提交于 2019-12-12 09:17:30
问题 I have a problem with the camera object when the surfaceCreated method of a SurfaceHolder.Callback is called for second time, I mean: I create an object camera in my onResume method from my activity, and this works fine showing the preview display, but when my activity goes to pause the surfaceview is destroyed and I have to release the camera object then if my activity comes to onresume android throws me a nullPointerException in my camera object. I'm not sure why is happening this, I putted

When does surfaceDestroyed() occur

天涯浪子 提交于 2019-12-12 08:29:28
问题 I'm having trouble figuring out when surfaceDestroyed() occurs. I am trying to make my threads stop running in the surfaceDestroyed() method (of a SurfaceView) but it appears that my surface is never actually destroyed...can someone tell me when this happens? Or how to trigger it? 回答1: Whenever you click return or home button and leave the activity you get: Activity onPause surfaceDestroyed and finally activity onDestroyed. When you return the surfaceView is recreated, however if you have

Mediacodec decoder always times out while decoding H264 file

半腔热情 提交于 2019-12-12 08:15:57
问题 I have been trying to decode a video file which is encoded via H264 encoding with Android's MediaCodec and tried to put the output of the decoder to a surface , but when I run the app it shows a black surface and in DDMS logcat I see that decoder timed out . I have parsed the file into valid frames first [reading 4 bytes first which indicates the length of the upcoming frame and then read length amount bytes which indicates the frame, then again reading 4 bytes for the length of the next

Camera Preview is stretched and skewed

自闭症网瘾萝莉.ら 提交于 2019-12-12 06:08:46
问题 How to solve the streching of image in my camera preview? Camera Preview Class public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback { private SurfaceHolder mHolder; private Camera mCamera; public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback { private SurfaceHolder mHolder; private Camera mCamera; public CameraPreview(Context context, Camera camera) { super(context); mCamera = camera; mHolder = getHolder(); mHolder.addCallback(this); //

Android Camera Frame Rendering

穿精又带淫゛_ 提交于 2019-12-12 06:04:47
问题 I am trying to render my camera frames in Android and make use of canvas,bitmap,onDraw() to display the frames on my Surfaceview. However my code performance which does the rendering on the Native side is taking up to 70% of my cpu. The rendering speed is good but CPU consumption is bad.The problem is that I have another overlaying surfaceview(surfaceview2) to display something else while I am rendering and capturing camera. I was wondering how may I reduce the cpu consumption and make use of

How to use setters and getters to pass data between classes in android

笑着哭i 提交于 2019-12-12 05:27:32
问题 I'm writing a program that has two classes, one that extends Activity and another that extends SurfaceView. The activity has an object of the SurfaceView class. I am trying to use setters and getters to send data between these two classes, but every time I try, eclipse says that the methods for setting and getting need to be static. I can't do this because I don't want them to be static. The Activity class contains the following methods: public float getxTouch(){ return xTouch; } public float

“Error 1” occurring during camera overlay in Android

▼魔方 西西 提交于 2019-12-12 05:16:14
问题 I have created an Activity that has a SurfaceView and a SurfaceHolder in order to create a Camera overlay. For some reason, I am getting the following in ADB: 04-08 10:54:06.747: E/Camera(1152): Error 1 . I am able to take a picture, but I cannot get any kind of preview. Here is the code I am using: public class MyActivity extends Activity implements SurfaceHolder.Callback, Camera.ShutterCallback, Camera.PictureCallback, OnClickListener { private Camera mCamera; private SurfaceView

How To Pause A SurfaceView Thread From An Android Activity

故事扮演 提交于 2019-12-12 03:57:01
问题 I have followed this tutorial in great detail and have managed to understand and replicate the functions that I need from an Android SurfaceView: http://obviam.net/index.php/moving-images-on-the-screen-with-androi/ I need to add a "pause" button in the game, which would be accessed from the activity. How would I go about pausing and then later continuing the thread from the activity? I have tried adding a button to test it but from that point I can't fathom how to control the thread from the

Android - concurrent access to the canvas safely?

一世执手 提交于 2019-12-12 03:40:56
问题 I'm making a grid + tile activity where tiles need to move across the grid. The grid (and tiles) are being drawn on a surfaceView in a separate thread to the UI (UI deals with touch events and pushes them onto a queue for the grid to process). This is all fine. I have a toolbar from which I can drag tiles. The toolbar is a View which has been added to the relative layout (and runs on the UI thread). No matter how many times i use synchronize or try to safeguard the canvas from being written