surfaceview

Android: surfaceView can't resume activity from pause()

耗尽温柔 提交于 2019-12-11 07:40:13
问题 I am testing surfaceView, basically the app jsut changes the color of the background. The app starts with no issue but when I "pause" the activity and "resume" it, the app is blocked in the "pause()" method loop. this is my code: import java.util.Random; import android.os.Bundle; import android.app.Activity; import android.content.Context; import android.graphics.Canvas; import android.util.Log; import android.view.Menu; import android.view.SurfaceHolder; import android.view.SurfaceView;

SurfaceView, onDraw and postInvalidate() something wrong

99封情书 提交于 2019-12-11 06:49:45
问题 App behave itself strangely. I have a class extends the SurfaceView and implements SurfaceHolder.Callback . I tried 3 options of code and only one works like i need (but I'm doubt that it is a right solution) and other have different behavior. So, my question is why and what is wrong and if "right" solution is wrong, so why it's work... Right for all: I tried setWillNotDraw(boolean flag) flag(true/false) In manifest set android:changeConfiguration="orientation" In main layout set background

Rendering a button over SurfaceView

坚强是说给别人听的谎言 提交于 2019-12-11 06:25:11
问题 I've been looking on google on how to do this, from what I've gathered it's not as easy as 123 because the surface view will just draw above it, the solution which people have said is to use an xml layout and make a layout and then add the surface view as a child and the button as a child to that. However I'm completely lost on this I'd really love to see some code on how to do this (I prefer looking at examples and trial and error for learning). My xml file <?xml version="1.0" encoding="utf

rendaring issue with surfaceview in viewflipper?

☆樱花仙子☆ 提交于 2019-12-11 05:16:51
问题 i am drawing a piechart by extending surfaceview to PieChart Class. now i am creating 2 objects for Piechart and adding to a VieWFlipper to swipe between those charts. now my problem is 2nd Piechart is not visible to the user if user swipes to 2nd view. but all the 2nd pies functionality is working. i am thinking like its refresh problem of the surfaceview. any help on this will be appreciable. the following is my PieChart class. class MyPieChart extends SurfaceView implements SurfaceHolder

Game crashing when device's password screen enabled

纵饮孤独 提交于 2019-12-11 05:15:59
问题 When using Microsft Exchange, Android activates its password screen wich the user needs to pass every time the device is turned on. I am making a game which is using SurfaceView run by a thread. I am using many static variables. If the device is turned off while playing, when I come back and enter the password, the game screen shows but with some bitmaps having wrong size and is frozen. In logs I see first NullPointerException with the non-UI thread then ANR error later. It looks like the

Surfaceview screenshot with line/ellipse drawn over it

主宰稳场 提交于 2019-12-11 04:55:41
问题 I have checked out many discussions on stackoverflow & other forums about programatically taking a screenshot of a surfaceview in android like the one below. Taking screen shot of a SurfaceView in android But, we'r facing a unique problem as it looks. We are drawing a line on a canvas of a surfaceview using the api canvas.drawline(). But when we use the example code provided in the numerous to take a screenshot of the surfaceview then the line is missing on the screen capture. The line drawn

Android SurfaceView empty

江枫思渺然 提交于 2019-12-11 03:54:51
问题 I am trying to make a simple 2D Android game. In this, game I'm trying to make some buttons to control the character, while the character is shown in a SurfaceView. Currently, the SurfaceView is rendering only a black screen. This is my MainActivity , which extends Activity : @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); GameView gm = (GameView)findViewById(R.id.snake_surface); setContentView(R

Getting image data continuously from camera, SurfaceView or SurfaceHolder

女生的网名这么多〃 提交于 2019-12-11 03:28:35
问题 So I have this camera preview set up with Camera , SurfaceView and SurfaceHolder . I have also an ImageView where I will be putting a modified version of the camera image and I want this to update lets say once every second. All code is ready and already working when I load images from "res" but I have a really hard time reading the image data from the camera. I've tried following already: Creating an intent for MediaStore.ACTION_IMAGE_CAPTURE and starting an onActivityResult getting a small

Android: How to draw a rectangle on a movable image such that the drawn rectangle also moves along with the image?

∥☆過路亽.° 提交于 2019-12-11 03:07:44
问题 I have an image which is movable throughout the screen. Now, I want to draw a rectangle on this image such that when I move the image the rectangle drawn on the image also moves. Currently I am able to draw the rectangle not on the image but on the SurfaceView which contains the image. My current code is below. public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int w=getWindowManager()

mediarecorder.stop() -> timed out waiting for incoming camera video frames

可紊 提交于 2019-12-11 02:33:29
问题 this is a little pain in the ass lately for me. Some of the devices on which I'm running my app, are getting this error. Basically, application starts recording, goes to background. When app is being brought to front, it should perform mediarecorder.stop() and restart recording. Somehow, some of the devices have problem with this. In those situations, I'm getting black screen and "timed out waiting for incoming camera video frames" message. Camera is locked and can't be used anymore even when