Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>haven't got enough time to explain (meeting with friends in a few minutes). I basically added some functions into "surfaceChanged()" (this is where you should start the preview).</p> <p>Therefore you don't need mCam.startPreview() in "surfaceCreated()"</p> <pre><code> 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"); mCam = Camera.open(); mCam.setPreviewDisplay(holder); //myCamera.startPreview(); } catch (IOException e) { Log.d("BROADCAST", e.getMessage()); } } public void surfaceDestroyed(SurfaceHolder holder) { Log.d("BROADCAST", "Surface Destroyed"); mCam.stopPreview(); mCam.release(); } public void surfaceChanged(SurfaceHolder holder, int I, int J, int K) { Camera.Parameters parameters = mCam.getParameters(); List&lt;Size&gt; previewSizes = parameters.getSupportedPreviewSizes(); Size bestSize = null; int bestDiff = 0; int diff = 0; for (Size size : previewSizes) { diff = Math.abs(K - size.height) + Math.abs(J - size.width); if (bestSize == null || diff &lt; bestDiff) { bestSize = size; bestDiff = diff; } parameters.setPreviewSize(bestSize.width, bestSize.height); mCam.setParameters(parameters); } //start preview of camera mCam.startPreview(); } </code></pre> <p>xml-file (you did a little copy &amp; paste error)</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /&gt; </code></pre> <p>Hope I could help :) I think, via setting the orientation, you could change the camera picture to portrait mode. :) (it's landscape right now) </p>
    singulars
    1. This table or related slice is empty.
    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