Android :: Regaining Focus Using SurfaceView
Mar 23, 2009
I'm currently getting to grips with Android, playing around with the Lunar Lander sample. I've found that if you navigate away from the app (eg, hit the call button) it will destroy the underlying surface (calling surfaceDestroyed). Navigating back (which will trigger onWindowVisibilityChanged) the app will crash, as it will try to draw to the surface without recreating it. Is there some code I can put in onWindowVisibilityChanged (or anywhere else) that will regenerate the SurfaceView's underlying surface and resume execution nicely? It feels like this should be a simple function call but I can't find anything in the API docs.
View 2 Replies
Aug 20, 2010
One using a Surfaceview, and the other using a custom view. According to the android SDK development guide, using a surface view is better because you can spawn a separate thread to handle graphics. Th SDK development guide claims that using a custom view with invalidate calls is only good for slower animations, less intense graphics.However, in my simple app, I can clearly see that using a custom view with calls to invalidate seems to render faster.What do you guys know/think about this?My touchEvent code is exactly the same, and my drawing code is exactly the same. The only difference is that one is all in the UI thread, and the other is using a tread to handle the drawing.
View 1 Replies
View Related
Aug 29, 2010
I loved the camera on the Eris and the Incredible, not only did they have a whole lot more of a crisp high-res detail, the auto-focus absolutely rocked. With my droid x, I can be getting a little artsy and focus on an object with the crosshair but it'll take me 20 tries to get it to lock on, its insane, I know I'm not getting too close to my subject because it will definitely eventually focus on that object if I try over and over and over again. It's not just close ups that I find myself and my buddy with this issue either. macro shooting mode does not help. My buddie's droid X has the same exact behaviors. Eris and incredible just LOCKED ON first try with even very low contrast / detail subjects, on top of that, have a ton better camera GUI when it comes to "click to focus". I know this thing ain't no SLR but, blows me away of how terrible the camera performance is vs. the HTC android based devices. Ihink motorola will fix this? I know this thing ain't no SLR but it just blows me away how the HTC android devices camera performance (except for video) blows the Droid X away.
View 9 Replies
View Related
Mar 25, 2009
Im creating a simple game using a SurfaceView for drawing the Graphics. It works fine, but now I tried to add a title screen, which is (for now) only a LinearLayout and a Start-button, specified in XML. However, when I click this button and try to switch to my SurfaceView (By doing setContentView(R.layout.game), the screen turns black. But if I do setContentView(R.layout.game) immediatly in my Activity.onCreate it works. But not if I start with my Title-screen and then try to switch
View 3 Replies
View Related
Apr 30, 2009
I am finally testing my application on a G1 and even though it works fine on the emulator, it crashes on the G1
It crashes when it does:
CODE:.........
And the view is defined like this:
CODE:..............
View 3 Replies
View Related
Jun 16, 2009
I want to play 2 videos one after one minimizing delay between each video. so I created 2 mediaplayer, one playing the current video and the other preparing to play the following video.
The 1st video is played correctely but I couldn't get the video track of the second video. only sound without any error.
This is my source code : (note that here, I am using files on sdcard but the application will use files on a web server. that's why I need to prepare the second video while the 1st is playing)
CODE:...................................
View 5 Replies
View Related
Sep 4, 2010
My app fc when activity that's using SurfaceView as content view calls startActivityForResult(...) and activity that has been started calls finish()
This does not happen if I change content view to something else than SurfaceView.
This would be the requested logcat:
CODE:..................
View 1 Replies
View Related
Dec 16, 2009
Look at this: http://nhenze.net/?p=172
They show that it is possible to put an GLSurfaceview on top on a SurfaceView. I hope it would be useful.
View 2 Replies
View Related
May 18, 2010
When exiting the activity in a thread in a SurfaceView. This log appears in this situation:.............
View 2 Replies
View Related
Sep 11, 2010
For years now I've maintained a Tandy Color Computer Emulator applet on my home page. With the purchase of an Incredible I decided to do a port. Getting it going in Android didn't take long but I'm really surprised how slow it runs. You can literally see the pixels painting. I know there are other successful Android emulators so I must be doing something wrong.
My approach was to use a SurfaceView for rendering. There's a separate thread that runs a virtual 6809 CPU. Whenever that thread updates the emulated video memory, it calls SurfaceHolder.lockCanvas() with a Rect describing the part of the screen requiring a repaint. Then it calls the gfx routines with the resulting Canvas...this is where I did a repaint() in AWT/Swing. The gfx routines are smart enough to just render what's in the clipRect. Perhaps I'm still stuck in AWT but I can't think of any way to make this thing run at an acceptable speed. I tried to coalesce the gfx calls but that didn't work either. Any thoughts?
View 1 Replies
View Related
Feb 11, 2009
I have a SurfaceView that is covering a portion of its parent, a RelativeLayout. I have a background image covering the full RelativeLayout area, and this is my Activity's main layout.
I would like to have the SurfaceView be transparent so that I can see through to the background image on its parent RelativeLayout. I have tried the approach shown in the API Demos example TranslucentGLSurfaceViewActivity, but this succeeds in making the transparency go all the way through my Activity to my desktop!
I'm using the "style/Theme.Translucent" theme on my activity, and setting this on my SurfaceView: mySurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);
The transparency to the desktop it kinda cool, but not what I'm trying to do! Is it possible to make a SurfaceView transparent only through to its parent?
View 2 Replies
View Related
Apr 24, 2009
I am stuck.My main activity creates and starts a SurfaceView.My app needs to access a listview via the options menu to change properties of the items shown in the view.Two strange things occur:
1.) When I scroll the listview quickly, the list sometimes gets farklempt.Words overlap each other.
2.) When I select the item and the app returns to the main activity, the thread is no longer alive.
If someone out there can offer help I will post the code.This will take a little effort.My code is loosely based upon LunarLander and the GLSurfaceView examples.If there is a good example (more recent example) someone can point me to, that would be boss.
View 8 Replies
View Related
Jun 10, 2009
I am creating a custom Widget which extends SurfaceView and I am planning to use it for camera preview.In the main activity I tried to implement some event listeners but can't catch any event.If I press a button the LogCat outputs "Continuing to wait for key to be dispatched" line.Does anyone know how to implement event listeners in main activity using SurfaceView classes?
View 3 Replies
View Related
May 31, 2009
I had it working with a normal View but that is to slow. I was told to use SurfaceView but can't figure out how to use OnKey with it and if I should use onDraw or draw? And how do I pass stuff to draw? does it happen automatically? code...
View 3 Replies
View Related
Jul 6, 2010
I'm trying to develop a little game, with 2D Graphics. I want my "gaming board" to be at a specific position on my screen, so that I can display in-game informations above and below the box. But since there is beginning to be a lot of Android phones out there, I was thinking about getting "dynamic" values so that I can adapt my font size to every device.
My game is not in full screen (but it could be, it's no big deal), but in a window with no title bar.
I'm using an extension of the default SurfaceView class, implementing SurfaceHolder.Callback. I tried writing the following method :
CODE:................
But the values returned are zeroes.
(even if it means changing display strategy) ?
View 1 Replies
View Related
May 19, 2009
I am using a SurfaceView, and wish to animate Drawables. All the animation tutorials I have seen concern using an ImageView, which as I understand is not a sensible approach from within a SurfaceView. Does anyone have any suggestions for doing frame-by-frame animation within a SurfaceView? Can it be done with openGL?
View 4 Replies
View Related
Aug 7, 2009
When is it necessary, or better to use a SurfaceView instead of a View?
View 3 Replies
View Related
Jan 16, 2010
I am currently starting a game engine in Android, first forray onto the platform and have the basics in place however i am unsure of the best way to approach resolution independence when using SurfaceView to draw graphics.
Looking for pointers as to how to keep the game / sprites etc all looking the same independent of the screen, obviously it wouldn't be efficient to scale all the sprites every frame or store many variations for differing resolutions
View 3 Replies
View Related
Aug 5, 2010
I have a database filled with records in the following format: . What I want my application to do is select records from an external database, and display those records on the phone screen using a SurfaceView.
Currently, I have an Activity, and a Service responsible for the record-gathering portion of the application. The Activity passes an intent to the Service, and the Service responds by returning the records that need to be displayed. The records are stored in my program as instances of the Data class, and merely have the screen-coordinates of where the element should be drawn in the View (I am just drawing a circle for every record in the DB).
For the sake of brevity, I won't include the service but I will include a skeleton of the Activity class and the Data that I wish to display.
CODE:.................
The problem that I am having pertains to the SurfaceView. I realize that many people are going to suggest that I use just a regular View, but my application involves a lot of elements, so a SurfaceView would be much more suitable for my needs. Below is a skeleton of my SurfaceView class that contains a nested class to manage the threads.
CODE:............
The problem that I'm having is that once I make the initial call to the Panel class, I'm going to be getting new records from the service, and consequently, my Info Map data-structure is going to get updated. However, my Panel class just gets stuck in a loop and never receives any new Data objects. All examples of SurfaceViews I've found have involved updating them methods within the SurfaceView class itself (e.g. touching the screen and creating a new image, etc.) Sadly, I'm stumped on this particular problem. Is there a better approach for designing my Activity/SurfaceView interaction? Is an additional View required?
View 1 Replies
View Related
Oct 13, 2010
I have an application with a SurfaceView and a MapView. They are displayed in a single view, like so:
CODE:.........................
Note the MapView comes before the SurfaceView. Because of this, the MapView is drawn "under" the SurfaceView, and all that I see is a black background, with the things that I draw on the SurfaceView showing. If I swap the order, and put SurfaceView first in the file and MapView second, the MapView is drawn, with none of the SurfaceView showing.
According to the SurfaceView Javadoc:
The surface is Z ordered so that it is behind the window holding its SurfaceView; the SurfaceView punches a hole in its window to allow its surface to be displayed. The view hierarchy will take care of correctly compositing with the Surface any siblings of the SurfaceView that would normally appear on top of it.
To me, this means that I should be able to put the SurfaceView first in the file, and have it "punch through" the MapView and display what it has. But, as it is, they seem to be two views, and only one is visible at a time.
After thought: I tried setting the background to #00000000 so that the alpha of the background would be zero (i.e. transparent), but it doesn't have any effect.
View 2 Replies
View Related
Aug 5, 2009
I'm work a game, when game over, I want to open a AlertDialog in the Surfaceview.
How can I open a AlertDialog in SurfaceView??
View 2 Replies
View Related
Nov 6, 2009
I want to write a graphics app using SurfaceView.
Basically my requirement is to draw some text frequently according to some time.
Is it possible to do this? can any one please provide me some source code which draws the text using SurfaceView.
View 2 Replies
View Related
May 1, 2010
I'm using SurfaceView to draw some stuff using canvas. The problem is that I want to show everything horizontally by default and keep it that way regardless the position of the device. I'm not using any layout XML file to show the SurfaceView; instead I just have a class that extends SurfaceView and I do setContentView(new Panel(this)).
View 1 Replies
View Related
Apr 27, 2010
Is there anyone who knows how to overlay a GLSurfaceview on a Surfaceview? The Surfaceview is used for the camera preview..
View 4 Replies
View Related
Jul 7, 2010
In my application, I have extended SurfaceView and ListView. I create a LinearLayout as below
mainForm = new LinearLayout(this); mainForm.setOrientation(LinearLayout.VERTICAL); mainForm.setLayoutParams(new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
I then add the SurfaceView and ListView to the mainForm and then setContentView(mainForm);
I also override onPrepareOptionsMenu and call menu.clear() and then dynamically create menus each time the menu button is pressed by the user. The application loads fine and the SurfaceView works fine as I directly draw images to it in a sleep loop. The ListView displays items and is desined to refreshed with new items. The options menu also displays once as well................................
View 2 Replies
View Related
Oct 28, 2010
Hi Guys! I'm coding a little app, but I don't know what I'm doing wrong. The App does the following: - Launches a Service which listens for an sms, then captures a picture with the cam and sends it to a predefined email adress. (no, i'm not trying to spy somebody out... I'm using the app to get a "3G-Webcam", sort of at least)
The problem: My App works great in the emulator, but as soon as I try it on my HTC Magic (cm6, android 2.2) it stops working.
CODE:.............
The permissions are all set, even the write to SD-card. What am I missing?
Note: I'm not using a surfaceview. Code:
CODE:......................
View 2 Replies
View Related
Sep 9, 2010
I am using SurfaceView to draw my game on the screen of the phone. Basically now I want to be able to draw Android Views on my View, such as a Button or ListView. I am simlpy getting a Canvas and then I draw on that... does anybody know how to draw AndroidViews (Button, ListView.) on my Canvas?
View 2 Replies
View Related
Jul 26, 2010
I am currently working on the app in which my media player class is singleton, and i want to play the video files. I use surfaceView for the video display part. But the problem i m facing is when i change the orientation, the previous playback disappears (if was playing) and the new surface view is getting created ..but the callback method surface created is not getting called in which i want to take further action.
View 2 Replies
View Related
Jun 6, 2009
I have a simple problem which makes me feel like a stupid. I really need help on this.
I have a SurfaceView which I created with Java code not XML. I created a MediaPlayer which shows its content on that SurfaceView.
When I use, setContentView(mPreview); // where mPreview is a SurfaceView
The video is played on the screen.
I need to add two buttons on the screen. So I tried something like this:
code:.........
This did not change anything. Still the video is displayed on full screen and no buttons appear. I am a java programmer both SE and ME. Things are done in this way on Java.
Does Android have a different approach?
View 4 Replies
View Related
Nov 17, 2010
I have an activity (say activity A) which displays video using a mediaplayer, rendered in a surfaceview.
The use case is to pause the video, start another activity (say activity B), then come back to activity A.
Activity A is stopped but not destroyed when going to B, which is good.
The surface view (since not visibile) IS destroyed (as observed from the notification callbacks). When coming back to activity A, and restarting the mediaplayer using start(), the media player does play back the audio, but video is not seen. Errors like this one are output on Logcat:
CODE;......
Unfortunately, using the new instance of SurfaceHolder as provided by surfaceCreated() doesn't help (i.e. provides the same error).
I have read in various posts a solution would be to reset the mediaplayer and restart it completely, however it is not efficient, as the end user would have to wait for the whole player preparation cycle + seekTo last position within the stream.
As shown with the fact the audio plays back, it should be a matter of plumbing between the the video decoder and the new surfaceholder/view.
What should be the best solution (best = fastest) to resume video playback when resuming the activity?
View 3 Replies
View Related