surfaceholder

Wallpaper crashes with error - queueBuffer: error queuing buffer to SurfaceTexture

落爺英雄遲暮 提交于 2021-02-07 11:52:32
问题 Live Wallpaper crashes, code below public void render(){ Canvas canvas = null; try{ canvas = this._surfaceHolder.lockCanvas(null); synchronized (this._surfaceHolder) { this.onDraw(canvas); } }catch(Exception e){ Log.w("Surface holder ", e.toString());} finally{ if(canvas != null){ this._surfaceHolder.unlockCanvasAndPost(canvas); } } } protected void onDraw(Canvas canvas) { this.renderBackGround(canvas); for (Renderable renderable : this._fishes) { renderable.render(canvas); } }; Crashes with

SurfaceHolder.lockCanvas() Returning null

半世苍凉 提交于 2019-12-29 00:10:23
问题 I'm making a game, and since I'm new to Android, I based the design off of the example LunarLander code. In its design, GameThread.doStart() is called from GameActivity , and the thread then runs everything from its GameThread.run() loop as shown below (much of the code has been removed for clarity): public class GameActivity extends Activity { public void onCreate(Bundle savedInstanceState) { gameView = new GameView(this); fl = new FrameLayout(this); fl.addView(gameView); setContentView(fl);

SurfaceHolder.lockCanvas() Returning null

℡╲_俬逩灬. 提交于 2019-12-29 00:09:07
问题 I'm making a game, and since I'm new to Android, I based the design off of the example LunarLander code. In its design, GameThread.doStart() is called from GameActivity , and the thread then runs everything from its GameThread.run() loop as shown below (much of the code has been removed for clarity): public class GameActivity extends Activity { public void onCreate(Bundle savedInstanceState) { gameView = new GameView(this); fl = new FrameLayout(this); fl.addView(gameView); setContentView(fl);

Android SurfaceView not retaining previously drawn objects

混江龙づ霸主 提交于 2019-12-25 02:30:04
问题 I am experimenting with SurfaceView. My requirement is to simply render a node (simple drawable) first. Then, render more nodes at a later point in time . The snippets of my thread's run method & my doDraw method are below. I am just trying to render 2 different drawables in subsequent passes while retaining both. The problem is it wipes away whatever gets written in 1st pass (see comment in code). How to retain the previously drawn object? public void run() { Canvas canvas; while (_running)

SurfaceHolder.lockCanvas returns null if the surface is not in the foreground

那年仲夏 提交于 2019-12-25 02:21:58
问题 I'm currently doing a test with a LiveWallpaper in Android. I am drawing something on the canvas using code that looks something like this: final SurfaceHolder holder = getSurfaceHolder(); Canvas c = new Canvas(); c = holder.lockCanvas(); // c becomes null c.save(); c.drawBitmap(currentBitmap); c.restore(); holder.unlockCanvasAndPost(c); This part is working fine under normal circumstances . However, I have a listener that executes this code whenever a setting is changed in the Settings that

Android: How to avoid errors on unlockCanvasAndPost method?

妖精的绣舞 提交于 2019-12-24 20:13:47
问题 Could anyone, please, help me to explain the following. How properly call the holder.unlockCanvasAndPost(canvas) method to avoid the errors like "Surface:unlockCanvasAndPost failed, no locked buffer" ? I mean, is there any way to check that canvas has been locked before? Currently, I have: try{ _surfaceHolder.unlockCanvasAndPost(canvasToUnlock); } catch(Throwable t){ } But I guess this is not proper. Thanks in advance. Answer on @njzk2 post: Yes. But in my case I faced with necessity to say

How to build a custom camera recorder app?

流过昼夜 提交于 2019-12-22 13:08:11
问题 I am trying to develop a custom camera video recorder. When my devices execute the start MediaRecorder method in beginRecording() in the Activity, the app crashes. I don't know what is wrong, because I follow the Google API Guide. My devices use Android 2.3 or higher version. In my Nexus S 4.1.1 executes ok, but in my Xperia 2.3.3 doesn't go, displaying this trace. My code is: private static final String TAG = "RecordVideo"; private MediaRecorder mRecorder = null; private Camera mCamera =

How to build a custom camera recorder app?

混江龙づ霸主 提交于 2019-12-22 13:06:14
问题 I am trying to develop a custom camera video recorder. When my devices execute the start MediaRecorder method in beginRecording() in the Activity, the app crashes. I don't know what is wrong, because I follow the Google API Guide. My devices use Android 2.3 or higher version. In my Nexus S 4.1.1 executes ok, but in my Xperia 2.3.3 doesn't go, displaying this trace. My code is: private static final String TAG = "RecordVideo"; private MediaRecorder mRecorder = null; private Camera mCamera =

java.io.IOException: setDataSource failed.: status=0x80000000

那年仲夏 提交于 2019-12-22 01:25:12
问题 I am trying to play url using media player in activity using: mediaPlayer = MediaPlayer.create(getApplicationContext(), Uri.parse("http://www.pocketjourney.com/downloads/pj/video/famous.3gp"), holder); It's working fine. Same code I use to set it as an live wallpaper in @onSurfaceCreated in WallpaperService , it's giving me following error log D/MediaPlayer( 4128): create failed: D/MediaPlayer( 4128): java.io.IOException: setDataSource failed.: status=0x80000000 D/MediaPlayer( 4128): at

Reopening camera after intent chooser is canceled

只谈情不闲聊 提交于 2019-12-21 17:45:13
问题 I have created a custom camera preview view CameraView which extends SurfaceView , and it also implements SurfaceHolder.Callback interface. The view operates with the camera. When you open the view it shows a camera preview. On the same screen there is also overlay with two buttons - 'Take picture', 'Choose from gallery'. The activity that holds the CameraView releases and reopens the camera in onPause() and onResume() methods. If I click the 'Choose from gallery' button, the following intent