Brilliant, thanks a lot. I didn't realize that you could specify your
own class in the XML.

I'll try it.

m.


On Feb 3, 7:29 pm, Dave Sparks <davidspa...@android.com> wrote:
> This is the layout for a little test app I wrote. You can see where
> the CameraView is a child of the top level layout and has a size of
> 240x160px. There are also a bunch of buttons for running various
> camera tests. I'll respond to your other questions in a separate post.
>
> <?xml version="1.0" encoding="UTF-8"?>
>
> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>     android:orientation="horizontal"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent">
>
>     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>         android:orientation="vertical"
>         android:layout_width="fill_parent"
>         android:layout_height="fill_parent"
>         android:layout_gravity="center_horizontal">
>
>         <com.android.davidsparks.CameraView
>             android:id="@+id/cameraView"
>             android:layout_marginTop="20dip"
>             android:layout_width="240px"
>             android:layout_height="160px"
>             android:layout_gravity="center_horizontal"/>
>
>         <LinearLayout xmlns:android="http://schemas.android.com/apk/
> res/android"
>             android:orientation="horizontal"
>             android:layout_width="wrap_content"
>             android:layout_height="wrap_content"
>             android:layout_gravity="center_horizontal">
>
>             <Button android:id="@+id/preview"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:text="@string/start_preview">
>             </Button>
>
>             <Button android:id="@+id/auto_focus"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:text="@string/auto_focus">
>             </Button>
>
>             <Button android:id="@+id/snap_picture"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:text="@string/snap_picture">
>             </Button>
>         </LinearLayout>
>
>         <LinearLayout xmlns:android="http://schemas.android.com/apk/
> res/android"
>             android:orientation="horizontal"
>             android:layout_width="wrap_content"
>             android:layout_height="wrap_content"
>             android:layout_gravity="center_horizontal">
>
>             <Button android:id="@+id/auto_shoot"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:text="@string/start_auto_shoot">
>             </Button>
>
>             <Button android:id="@+id/test_button"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:text="@string/test_button">
>             </Button>
>
>             <Button android:id="@+id/record_button"
>                 android:layout_width="wrap_content"
>                 android:layout_height="wrap_content"
>                 android:text="@string/start_record">
>             </Button>
>         </LinearLayout>
>     </LinearLayout>
> </LinearLayout>
>
> On Jan 28, 12:22 pm, Vternal Android <mdunsm...@gmail.com> wrote:
>
> > I appreciate your help.
>
> > I wanted to try a few things before I got back to you and I've
> > definitely made some progress.
>
> > My application is a client which streams audio and send jpeg pictures
> > to a remote server. I want to use the camera to take periodic shots
> > and I want to capture and stream audio from the Mic.
>
> > I have a Google G1 phone from T-Mobile, not an unlocked development
> > special. The UI framework is built and I am now ready to build the
> > guts (FYI a Windows version of what I am attempting to run on Android
> > is already running). There are three difficulties I am having that are
> > holding me up.
>
> > The first is my desire to display my subclass of SurfaceView (I was
> > already doing this) within a layout. You say: "I made the CameraView a
> > child of the activity view and set its properties in the XML layout".
> > I am sorry to say that I am still confused :-). Could you send me a
> > code snippet and and xml example? Then I think it would be very clear.
>
> > My second problem is that I cannot get the MediaRecorder to function
> > either in the phone or on the emulator (I do not know if the mic is
> > emulated). Here is my code:
>
> >                 try {
> >                         mRecorder = new MediaRecorder();
> >                         
> > mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
> >                         mRecorder.setOutputFormat
> > (MediaRecorder.OutputFormat.THREE_GPP);
> >                         mRecorder.setAudioEncoder
> > (MediaRecorder.AudioEncoder.AMR_NB);
> >                         mRecorder.setOutputFile("vternal.3gp");
> >                         mRecorder.prepare();
> >                         mRecorder.start();   // Recording is now started
> >                 }
>
> > at the line: "mRecorder.start()", it crashes. I got this code from the
> > android website. I thought it might be a permissions thing, but I have
> > all the permissions set that could possibly be related. Here is my
> > AndroidManifest.xml lines:
>
> > <uses-permission android:name="android.permission.RECORD_AUDIO"></uses-
> > permission>
> > <uses-permission android:name="android.permission.CAMERA"></uses-
> > permission>
> > <uses-permission android:name="android.permission.INTERNET"></uses-
> > permission>
>
> > Can you throw any light on this for me, I just can't see what I could
> > be doing wrong.
>
> > Lastly, I have been having a problem with the ImageView widget. I want
> > to display an perfectly valid jpeg file in a layout. I use setImageUri
> > () to do this on a pointer to the ImageView.
> > The Uri is contructed from a local file name, as follows:
>
> >                 ImageView image = (ImageView)mVTB.findViewById(R.id.image);
>
> >                 mJpegFile = new File( "/sdcard/dcim/Camera/latest.jpg" );
> >                 Uri u = Uri.fromFile( mJpegFile );
>
> > Then I execute:
>
> >                 image.setImageURI(u);
>
> > and nothing is displayed. If I put the very same jpeg into a resource,
> > everything works. The value of u.toString is 'file:///sdcard/dcim/
> > Camera/latest.jpg'. Perhaps setImage does not handle file resources?
> > How then can I display a jpeg? How does the Camera do it?
>
> > Any help will be much appreciated.
>
> > m.
>
> > On Jan 25, 9:33 am, Dave Sparks <davidspa...@android.com> wrote:
>
> > > The preview surface on the G1 can be any size within a factor of 2x
> > > (if I remember correctly) of the dimensions of thecamerapreview. By
> > > default thecamerapreview frame is 480x320, so you should be able to
> > > get away with 240x160.
>
> > > In my test application, I created a subclass of SurfaceView called
> > > CameraView that manages all thecamerafunctionality. I made the
> > > CameraView a child of the activity view and set its properties in the
> > > XML layout.
>
> > > On Jan 24, 12:33 am, Vternal Android <mdunsm...@gmail.com> wrote:
>
> > > > Does anyone know if it is possible to have theCameraPreview surface
> > > > be smaller than fullscreen. I want to display thecamerapreview in
> > > > the upper portion of the display and have controls below it.
>
> > > > Ideally I want to create a layout in XML which defines where the
> > > >camerapreview is and lets me add the other controls easily.
>
> > > > I have been using the APiDemos CameraPreview source as my guide. It
> > > > sets the content view directly to the whole screen Surface and doesn't
> > > > use resources in layout at all. I've tried various ways around it. The
> > > > best being to get hold of the Surface being used by thecameraand
> > > > setting its size. In the emulator this gives a small simulatedcamera
> > > > in the top left, but behind, flickering, is screen of the previous
> > > > activity.
>
> > > > On the phone itself you get just a blank screen.
>
> > > > Any help would be appreciated. I can just about live with fullscreen
> > > > if noting can be done but there must be a way.
>
> > > > martin dunsmuir
> > > > mdunsm...@gmail.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to