Note that there are some explanatory texts on larger screens.

plurals
  1. POCamera Preview: No errors but no picture :-(
    primarykey
    data
    text
    <p>Have read the books and hints, got rid of all compile errors and warnings and put in some debug statements.</p> <pre><code>package com.cit.BroadcastSim; import java.io.IOException; import android.app.Activity; import android.hardware.Camera; import android.os.Bundle; import android.util.Log; import android.view.SurfaceHolder; import android.view.SurfaceView; public class BroadcastActivity extends Activity implements SurfaceHolder.Callback { public Camera myCamera; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.broadcast); // Inflate the broadcast.xml file Log.d("BROADCAST", "Creating the Activity"); SurfaceView cameraSurface = (SurfaceView)findViewById(R.id.camerasurface); SurfaceHolder cameraHolder = cameraSurface.getHolder(); cameraHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); cameraHolder.addCallback(this); Log.d("BROADCAST", "Now wait for some CallBacks"); } public void surfaceCreated(SurfaceHolder holder) { // Surface created, now it is possible to set the preview Log.d("BROADCAST", "Surface Created"); try { Log.d("BROADCAST","CAMERA: NOT NULL"); myCamera = Camera.open(); myCamera.setPreviewDisplay(holder); myCamera.startPreview(); } catch (IOException e) { Log.d("BROADCAST", e.getMessage()); } } public void surfaceDestroyed(SurfaceHolder holder) { Log.d("BROADCAST", "Surface Destroyed"); myCamera.stopPreview(); myCamera.release(); } public void surfaceChanged(SurfaceHolder holder, int I, int J, int K) { Log.d("BROADCAST", "Surface Changed"); myCamera.stopPreview(); myCamera.release(); } } </code></pre> <p>In the DDMS debugger, I get a log message for 'Creating the Activity' followed by 'Now wait for some CallBacks' and nothing more in terms of my Debug messages so I think Callback is not working - for the life of me can't see where I have got it wrong.</p> <p>In the manifest I have</p> <p> </p> <p>The Activity XML page has</p> <pre><code>&lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/Broadcast" /&gt; &lt;SurfaceView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/camerasurface" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Finally, on the Android phone (HTC Wildfire), the page loads, the textView message appears at the top left and that is all.</p> <p>Should mention that I am very new to this platform and accept that I might have missed something very very basic.</p> <p>Any ideas/comments will be very much appreciated,</p> <p>Oliver</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload