Android :: Possible To Start Surface View With Game Thread Anytime / Other Than At Startup Of Program?
Aug 7, 2010
I've read several example programs and tutorials to try and solve my problem but they all seem to go the same way.I've used a couple Activities and xml documents to create a menu that loads when my game starts. When the user clicks the "Start The Game" button, it loads a new Activity that sets the view with my game thread and all of the game properties.I know this activity works because I've run it alone as its own project, but every way I've tried to start it after the Menu, I get a nullPointerException and it force closes.I read the SurfaceViewOverlay tutorial and attempted to use that implementation, but I'm using a SurfaceView, not a GLSurfaceView. I'm debating rewriting my entire program to use OpenGL but I figured I would see if anyone else knows what I'm doing wrong here.If you need the code snippets I can paste some here, but it's not really the specific code that's wrong, I think it's the way I'm using(abusing) the language.
View 1 Replies
Aug 7, 2010
I've read several example programs and tutorials to try and solve my problem but they all seem to go the same way. I've used a couple Activities and xml documents to create a menu that loads when my game starts.When the user clicks the "Start The Game" button, it loads a new Activity that sets the view with my game thread and all of the game properties.I know this activity works because I've run it alone as its own project, but every way I've tried to start it after the Menu,I get a nullPointerException and it force closes.I read the SurfaceViewOverlay tutorial and attempted to use that implementation, but I'm using a SurfaceView, not a GLSurfaceView.I'm debating rewriting my entire program to use OpenGL but I figured I would see if anyone else knows what I'm doing wrong here.If you need the code snippets I can paste some here, but it's not really the specific code that's wrong.
View 1 Replies
View Related
Apr 1, 2009
I have an Activity that was created based on the TriangleRenderer example. It works flawlessly as a standalone project, but when I use it as the tab of a tabhost there is a problem. At startup the whole activity is just black - I can get touch events and do everything else but it doesnt show anything. When I change the orientation (and therefore recreate the activity) it all works well. Maybe the problem comes from the View focus. My SurfaceView is not focused when created inside of the tabhost. I tried to fiddle around with the methods available in my onCreate() and onPostCreate(), but couldnt find a way to get the SurfaceView focused. The following sourcecode blocks in the guardedRun() method because needToWait() is true because !mHasFocus is true. If I exclude the ! mHasFocus, it goes on but shows a black View anyways. Do you have any idea why it does work after orientation change, but not at the first startup? The Activity looks quite simple.
View 2 Replies
View Related
Jan 22, 2009
How do I create blur surface from android.view.Surface?
View 2 Replies
View Related
Aug 29, 2009
I am trying to add an image on surface view. I have coded...
View 5 Replies
View Related
Nov 11, 2010
I want to change the size of surface view at run time when it is changed to Landscape Mode?
View 1 Replies
View Related
May 3, 2010
I'm trying to render a 640x480 RGB565 image using OpenGL ES on Android using GLSurfaceView and Native C code. Initially I had a 0x0501 error with glTexImage2D, which I was able to resolve by changing the image dimensions. But now, in the "drawFrame" call, when I do glDrawTexiOES to resnder the texture, I'm getting the following error on the Logs: drawtex.c:89: DrawTexture: No textures enabled I'm already doing glEnable(GL_TEXTURE_2D), is there anything else I should do? Is there a complete example showing GLSurfaceView with native code using textures?
View 4 Replies
View Related
May 29, 2010
I have a simple program that draws the preview of the Camera into a SurfaceView. What I'm trying to do is using the onPreviewFrame method, which is invoked each time a new frame is drawn into the SurfaceView, in order to execute the invalidate method which is supposed to invoke the onDraw method. In fact, the onDraw method is being invoked, but nothing there is being printed (I guess the camera preview is overwriting the text I'm trying to draw).
This is a simplify version of the SurfaceView subclass I have:
public class Superficie extends SurfaceView implements SurfaceHolder.Callback {
SurfaceHolder mHolder; public Camera camera; Superficie(Context context) { super(context);
mHolder = getHolder(); mHolder.addCallback(this); mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
} public void surfaceCreated(final SurfaceHolder holder) { camera = Camera.open();
try { camera.setPreviewDisplay(holder); camera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera arg1) { invalidar();
} } ); } catch (IOException e) {} } public void invalidar(){ invalidate(); }
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
Camera.Parameters parameters = camera.getParameters(); parameters.setPreviewSize(w, h);
camera.setParameters(parameters); camera.startPreview(); }
@Override public void draw(Canvas canvas) { super.draw(canvas);
// nothing gets drawn :( Paint p = new Paint(Color.RED);
canvas.drawText("PREVIEW", canvas.getWidth() / 2, canvas.getHeight() / 2, p);
} }
View 1 Replies
View Related
Jul 6, 2010
My objective is to run a glowing animation on an image.I am changing the image alpha to produce this effect.
I have used basic AlphaAnimation provided in android framework but found that its slowing down other animations. So i extended a class from SurfaceView and created a thread to update it. ( Again here, i am manipulating alpha of the image ).
Everything seems fine, except that i am not able to draw a transparent image onto SurfaceView.Its showing black color on the transparent areas of the bitmap.code...
View 1 Replies
View Related
May 27, 2009
How do you create a Java program that runs on startup, in the background? I need to create this, or some type of java/c service.
I've created this for an iPhone, and I'm porting my app to the android.
View 3 Replies
View Related
Aug 23, 2010
I have a SurfaceView that is being used to draw custom animations and I would like to overlay them onto a live-feed from the phone's camera. Currently, the SurfaceView that contains the animations has a white- background, but if I were to overlay them onto the phone's camera feed, they would have to be transparent. The camera and animation drawing cannot be done on the same SurfaceView. Is it possible to make a SurfaceView transparent? What is the best course to pursue the use of multiple views? My end goal is to essentially overlay the contents of another SurfaceView onto the Camera SurfaceView.
View 2 Replies
View Related
Oct 1, 2010
I have a simple activity program in android. Basically the class just extends Activity.
But when I start it I get a ClassCastException in the constructor of my class. I don't even have a constructor defined, so it must be in the constructor of the superclass which is Activity. Unfortunately the debugger doesn't give any detailed information on what class it is trying to cast. Here is the stacktrace:
Thread [<1> main] (Suspended (exception RuntimeException))
ActivityThread$PackageInfo.makeApplication(boolean, Instrumentation) line: 649
ActivityThread.handleBindApplication(ActivityThread$AppBindData) line: 4232
ActivityThread.access$3000(ActivityThread, ActivityThread$AppBindData) line: 125
ActivityThread$H.handleMessage(Message) line: 2071
ActivityThread$H(Handler).dispatchMessage(Message) line: 99
Looper.loop() line: 123
ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626
NativeStart.main(String[]) line: not available [native method]
And when I look into this runtimeexception I get:
detailMessage "Unable to instantiate application com.test.MyApp: java.lang.ClassCastException: com.test.MyApp" (id=830067694464)
The only code is:
package com.test;
import android.app.Activity;
public class MyApp extends Activity {
}
View 3 Replies
View Related
Aug 23, 2010
I have a SurfaceView that is being used to draw images, and I would like to overlay them onto a live-feed from the phone's camera. Currently, the SurfaceView that contains the images have a white-background, but if I were to overlay them onto the phone's camera feed, they would have to be transparent. The camera and animation drawing cannot be done on the same SurfaceView. What is the best course to pursue the use of multiple views that involve managing the camera and drawing images? Is it possible to make a SurfaceView transparent?
View 4 Replies
View Related
Apr 9, 2009
how to define a service that launch automatically at startup and / or when installation without having to go through "activity". I look beautiful everywhere, I do found that the functions and BindService but StartService which requires action outside.
View 5 Replies
View Related
Oct 5, 2010
I am working on video renderer application which need surface and control of surface. And through isurface i can register heap buffer to that surface and post buffer operation. I have gone through android_view_surface.cpp file. It is having all required APIs which are helpful for my application. But i don't know how can i implement it. What are the procedures to get access of those APIs.
View 2 Replies
View Related
Apr 11, 2010
Hello, I use a thread for drawing to the canvas. By coincidence I recognized that in the program always jumps into the finally part. After view.onDraw(c); is reached it steps back to synchronized (surfaceHolder) and then it steps into the finally part. This happens every time. This means to me that every time exceptions are thrown.
Can anybody explain why this is so?
CODE:......................
View 3 Replies
View Related
Feb 12, 2010
i think a simple question but i did not find anything about doing it right.I want to start a mediaplayer from my app and send that player a file to play(stream).Would be nice to automatically choose the player associated with the mime type of the file i process to the player.The only way to start an app is this one. But i wonder if there is a android native way.
View 2 Replies
View Related
Jun 28, 2013
I have created an simple game on Windows (7). The game is great but I think it will be better on a smartphone / tablet.
Now my question. Is it possible to port my game from Windows to Android or do I have to program it from scratch new? It would be also ok if I can use parts of my code on Android. I have a basic knowledge on android-programing.
View 1 Replies
View Related
Jan 14, 2010
What is most efficient way of keeping a check on time within a game thread? Currently I create a new Date() when the game starts and was thinking of creating another Date() within the game thread and comparing it with the first one. But with a screen refreshing at around 60fps (hence a new date object each time), I can't help thinking this is rather inefficient. What other ways are there of doing this?
View 8 Replies
View Related
Nov 14, 2010
I am developing an Android app and I am doing some heavy work (bringing data from an online web page and parsing it to store in database) in a service. Currently, it is taking about 20+ mins and for this time my UI is stuck. I was thinking of using a thread in service so my UI doesn't get stuck but it is giving error.
View 1 Replies
View Related
Oct 9, 2010
I had a message pop up saying I needed a spyware, malwRe, antivirus program. Any ideas about this? This only happened after I downloaded a chess game off the market
View 3 Replies
View Related
May 13, 2009
I'm trying to do a program and I wanna know how do I put the program in background.But it's no put the program in background, the program will start in background and close when the user open again and press close. Somebody knows where I can find?I looked in the references and I didn't find.
View 4 Replies
View Related
Jul 14, 2009
I'm a new Android developer. I would like to make a simple game using the SurfaceView (Canvas drawing).the game has a a custom Object name Box. Box can draw itself and need to get an event when it is clicked. when it does, there is an animation sequence coming out of the box like a "jumping clown". I have several Boxes on the screen when each of them can be activated. Several Boxes animation can also be presented simultaneously.Here it gets tricky: Since I have a "complicated" animation sequence, each Box extends SurfaceView. The problem is I haven't figured it out how can I handle several SurfaceView's drawing using only one Thread (in order to present an animation I need to use one) and also how can I get the onClick/ onThouch event from my Activity to each of my Boxes.
The LunarLanding example in the SDK uses only one Thread but also uses only one SurfaceView which manage the animation of the game components (there are no several game components SurfaceViews). Also, there is no need to get onTouch event, so this example doesn't match to my case. I have several questions about what is the right approach do code this:
1. Should I use Box extends SurfaceView?
2. Can SurfaceView gets user events like onTouch/onClick?
3. Is there a way to add to the "main" SurfaceView another SurfaceView (Box)?
4. If none of the above questions is positive, should I use one SurfaceView (and one Thread) and try to map the other Boxes on the screen for user event handling. I mean Box only paints itself but the user event is being handled by me (not by the OS).
5. Should each Box (SurfaceView) should handle it's own Thread in case of animation (it is not good design but it is also an option)?
6. do you have any other proposal?
View 4 Replies
View Related
Aug 13, 2010
In my game when the user completes a stage, I want the main game thread to pause/sleep/wait and a new activity to be launched called StageClear that displays information about points scored etc. After this has been displayed and the user has pressed continue I want the original game thread to resume where it left off. I have tried to implement this but have so far been unsuccessful, probably because I'm new to dealing with multiple threads and also the idea of synchronizing them. I most recently tried to implement a shared package-visible object that could notify after wait was called on itself, but I am getting errors in eclipse so it won't even compile, I think because though the object is declared public in an inner class, it cannot be seen or recognised by my activity elsewhere in a file in the package. I have already built both activities but my issue is getting the main game one to launch the other, and pause whilst it waits for this activity to finish, before the main game thread continues execution.
View 1 Replies
View Related
Mar 8, 2010
I have written a very simple game with some simple animations, but I've noticed that when the phone checks email, or several other apps are running, the animations that update in my thread start behaving slowly or choppy. This is a problem as the game mechanic requires some careful timing of your screen touches based on the animations. So if it starts behaving erratically, the game doesn't really work well - and isn't much fun.
Is there a way to prevent this? Can my threads have a higher priority when they need to run?
View 3 Replies
View Related
Dec 8, 2009
I am getting the 'AudioTrack::start called from thread' when starting an AudioTrack. I am using it in a thread. I asume I shouldn't but why? I see it as a major limitation.
View 4 Replies
View Related
Jul 8, 2010
What I want to do is I am working on a game of life program. I want to take the time delay and make it a preference, but I want to make it available for people to type in a specific time. The number can be in miliseconds or seconds. However I'm a little stuck on how to proceed, I haven't been able to find a simple preference that already handles this, but there might be one. Is there an easy way to make this preference and confirm that the entered data is an integer or afloat?
View 1 Replies
View Related
Mar 25, 2009
We are trying to launch C program application (for example, Helloworld) at start-up on ARM-based target board. We copied the application in /system/bin and modified the init.rc script to add the entry of the application in "on boot". But, still, the application does not launch at the start-up.
View 2 Replies
View Related
Aug 1, 2009
The following code leads to "java.lang.IllegalThreadStateException: Thread already started." the second time it is run through on the program This happens the second time updateUI.start() is called. I've stepped through it multiple times and the thread is called and completely runs to completion before hitting updateUI.start(). Calling updateUI.run() avoids the error but causes the thread to run in the UI thread (the calling thread, as mentioned in other posts on SO), which is not what I want. Can a Thread be started only once? If so than what do I do if I want to run the thread again? This particular thread is doing some calculation in the background, if I don't do it in the thread than it's done in the UI thread and the user has an unreasonably long wait.
View 5 Replies
View Related
Jan 5, 2010
I currently have a Napster To-Go subscription that I use with my Creative Zen, and on my PC at work. But now that I have the Droid, I would much rather stream music to the phone. I currently use Pandora (One) and I like it but I would really like to listen to full albums and make my own playlists; basically listen to whatever I want. I heard that Napster had an App but decided to not to release it, and I will be canceling my subscription as soon as an alternative is found that I can use on the Droid (I never really liked the Napster app anyway). Are there any Subscription Play-anything/Anytime apps?
The following I have looked at:
Napster - No App Release Planned
Rhapsody - Supposed to launch in 2009, Delayed?
Spotify - Supposed to launch in 2010 in US.
Have I missed any alternatives?
View 1 Replies
View Related