Main App & SurfaceHolder?

by gabehabe » Tue, 16 Dec 2008 06:28:33 GMT

Sponsored Links
 Hey guys, total Android noob here. :)

For my first app, I'm having a go at developing a simple video camera
(There isn't one yet~!)

So I've been reading through the docs, and I've come up with a tiny
bit of code.

...Sorry if there's code tags. (I'm a mod over at another forum, I
know the rules!) ;)

Anyway, I digress.


import android.os.Bundle;
import android.hardware.Camera;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        Camera cam =;

I'm stuck on assigning something with cam.setPreviewDisplay();

I've looked in the docs, and come across this method. I know it takes
a SurfaceHolder as a parameter.

But I can't instantiate a SurfaceHolder object, so I'm assuming the
main app has one?

Thanks in advance,


Main App & SurfaceHolder?

by Stoyan Damov » Wed, 17 Dec 2008 07:34:39 GMT

 Create a new view, subclassing SurfaceView, set this view for your
activity, and then you can call getHolder to obtain the surface
OR, read 
OR, read LunarLander's source code ;)



Sponsored Links

Other Threads

1. Bringing an Activity to front


i have multiple instances of the same activity, is there a way to
programatically bring one of the instances to the front? I've read
some existing threads and it seems there's no way to do this... My
specific use case is of a Snooze/Dismiss type of screen. The problem
would appear when the user sets 2 alarms close by:
- first alarm is triggered, so first instance of the activity is
- user doesn't dismiss the alarm
- second alarm is triggered, so the second activity instance is
created and comes to the front
- user doesn't dismiss this either
- first activity instance reminds the user about the first alarm
(sound can be played, but the UI is still somewhere in the background)

Any suggestions?



2. how to know data successfully saved on server

You must have written code for "posting data to server" in a thread.
So when you press the BACK key terminate that thread and show a screen
that "Failure Data posting to server" to user



3. how to know data successfully saved on server

4. Significance of "..." in doInBackground(Params...) of AsyncTask

5. mouse hover events

6. ADT causing CDT to build all C projects on Android app launch??

7. Debugging power management - how to determine cpu state?