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
app.
(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.

package com.android.hello;

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

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

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,
Danny

--~--~---------~--~----~------------~-------~--~----~



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
holder.
OR, read 
 http://code.google.com/intl/bg/android/reference/android/view/SurfaceView.html 
OR, read LunarLander's source code ;)

Cheers,
Stoyan




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Other Threads

1. Emulator closes when attempting to enter full screen mode

If I am in the emulator and press alt+enter to get full screen, the
emulator closes and the following output is written in the console:

[2009-12-11 15:01:00 - Emulator]### Error: could not create or resize
SDL window: No video mode large enough for 1050x1680

Note that I have my monitor flipped to the side. The resolution isnt
1680*1050, but 1050*1680. This bug has only happened on this
resolution with flipped monitor. I have tried maybe three different
resolutions, but nothing bigger than this. The error is replicable
since it happens everytime I try to go into fullscreen mode. I would
very much prefer if the action was cancelled instead of the emulator
closing.

If there is a more appriopriate place to file a bug report, then
please inform me and I will file it there.

-- 

2. awakenScrollBars() not showing scrollBar in custom View

Hi,

I have a custom view. I am scrolling the view vertically using scrollTo
(int, int). But the scrollbar is not showing when scrolling. I tried
awakenScrollBars(). But its not drawing the scrollbar. I also put
setVerticalScrollBarEnabled(true). Whether I am missing something
here ?

Thanks

-- 

3. Fwd: xor algorithm used when gc in dalvik

4. Playing Flash file in Android

5. URLconnection.setConnectTimeout doesn't work?

6. xor algorithm used when gc in dalvik

7. lock screen always portrait