Checkout CameraPreview in the APIDemo app.

On the emulator the camera is simulated as you describe. Need to run
in a real phone with the Camera to see real pictures. On the other
hand, taking pictures works in the emulator, just gives you the same
jpg every time.

There is no video (other than the preview frames).

m.


On Feb 4, 7:21 am, shobhit kasliwal <shobhit.kasli...@gmail.com>
wrote:
> Hi
>
> I am trying to use camera in my application but when I tried to use the
> Camera class it does not display any error but When I run the application in
> emulator it displays the one rectangle moving with boxes in background. I
> tried to search it on web but I did not find any solution. Can you tell me
> what can be the problem ?
> if you have any tutorial or code which shows how to work with camera and
> video camera that would be really helpful for me.
>
> Thanks and Regards
> Shobhit Kasliwal
>
> On Tue, Feb 3, 2009 at 10:15 PM, Vternal Android <mdunsm...@gmail.com>wrote:
>
>
>
>
>
> > I finally had a revelation related to the problems I have been having
> > with setImageURI.
>
> > My images were too big. 2048x1586 to be precise. I brought them down
> > to 960x640 and it all works. Logcat reported the attempted allocation
> > of over 6Mb by my application and this is what gave me the clue.
>
> > So for those who are having problems with setImageURI, be aware of
> > this difference between the emulator and the real device.
>
> > m.
>
> > On Jan 28, 10:22 am, 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 thecamerato 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 theCamerado 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
>
> --
> Shobhit Kasliwal
> Graduate Assistant
> School of Information Technology
> Illinois state university, Normal IL- 61761
--~--~---------~--~----~------------~-------~--~----~
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