Skip to content

Commit fc3f8e6

Browse files
sparky-rAndroid (Google) Code Review
authored andcommitted
Merge "Remove references to sample application" into ics-mr0
2 parents d37e2b3 + abe2dec commit fc3f8e6

File tree

2 files changed

+16
-37
lines changed

2 files changed

+16
-37
lines changed

docs/html/training/camera/cameradirect.jd

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,11 @@ or something fully integrated in your app UI, this lesson shows you how.</p>
4545
process of directly controlling the camera. As Android's own Camera application does, the
4646
recommended way to access the camera is to open {@link android.hardware.Camera} on a separate thread
4747
that's launched from {@link android.app.Activity#onCreate onCreate()}. This approach is a good idea
48-
since it can take a while and might bog down the UI thread. However, in the sample application
49-
associated with this lesson, opening the camera is deferred to the {@link
48+
since it can take a while and might bog down the UI thread. In a more basic implementation,
49+
opening the camera can be deferred to the {@link
5050
android.app.Activity#onResume onResume()} method to facilitate code reuse and keep the flow of
5151
control simple.</p>
5252

53-
<pre>
54-
private void openCameraPerIdAndSetPreview() {
55-
if (! safeCameraOpen(mCameraId)) {
56-
mCameraId = getFirstRearCameraID();
57-
safeCameraOpen(mCameraId);
58-
}
59-
60-
mPreview.setCamera(mCamera);
61-
}
62-
</pre>
63-
64-
<p>Since API level 9, the camera framework supports multiple cameras. If you use the
65-
legacy API and call {@link android.hardware.Camera#open open()} without an
66-
argument, you get the first rear-facing camera. Dealing with multiple cameras
67-
is an advanced topic and beyond the scope of this lesson. If you are really
68-
interested, check out the implementation of {@code getFirstRearCameraID()} in
69-
the sample app (downloadable at the top).</p>
70-
7153
<p>Calling {@link android.hardware.Camera#open Camera.open()} throws an
7254
exception if the camera is already in use by another application, so we wrap it
7355
in a {@code try} block.</p>
@@ -78,7 +60,7 @@ private boolean safeCameraOpen(int id) {
7860

7961
try {
8062
releaseCameraAndPreview();
81-
mCamera = Camera.open(mCameraId);
63+
mCamera = Camera.open(id);
8264
qOpened = (mCamera != null);
8365
} catch (Exception e) {
8466
Log.e(getString(R.string.app_name), "failed to open Camera");
@@ -97,6 +79,10 @@ private void releaseCameraAndPreview() {
9779
}
9880
</pre>
9981

82+
<p>Since API level 9, the camera framework supports multiple cameras. If you use the
83+
legacy API and call {@link android.hardware.Camera#open open()} without an
84+
argument, you get the first rear-facing camera.</p>
85+
10086

10187
<h2 id="camera-preview">Create the Camera Preview</h2>
10288

@@ -113,13 +99,10 @@ data from the camera hardware the application.</p>
11399

114100
<pre>
115101
class Preview extends ViewGroup implements SurfaceHolder.Callback {
116-
...
117102

118103
SurfaceView mSurfaceView;
119104
SurfaceHolder mHolder;
120105

121-
...
122-
123106
Preview(Context context) {
124107
super(context);
125108

@@ -137,14 +120,13 @@ class Preview extends ViewGroup implements SurfaceHolder.Callback {
137120
</pre>
138121

139122
<p>The preview class must be passed to the {@link android.hardware.Camera} object before the live
140-
image preview can be started, as seen in {@code setCamera()} method of the sample,
141-
as shown in the next section.</p>
123+
image preview can be started, as shown in the next section.</p>
142124

143125

144126
<h3 id="TaskStartPreview">Set and Start the Preview</h2>
145127

146128
<p>A camera instance and its related preview must be created in a specific
147-
order, with the camera object being first. In the sample application, the
129+
order, with the camera object being first. In the snippet below, the
148130
process of initializing the camera is encapsulated so that {@link
149131
android.hardware.Camera#startPreview Camera.startPreview()} is called by the
150132
{@code setCamera()} method, whenever the user does something to change the
@@ -183,9 +165,8 @@ public void setCamera(Camera camera) {
183165
<h2 id="TaskSettings">Modify Camera Settings</h2>
184166

185167
<p>Camera settings change the way that the camera takes pictures, from the zoom
186-
level to exposure compensation. This example doesn’t do a whole lot with camera
187-
settings, but the APIs provide a wide array of options. The {@code surfaceChanged()} method in the
188-
sample app demonstrates how to get and set camera parameters:</p>
168+
level to exposure compensation. This example changes only the preview size;
169+
see the source code of the Camera application for many more.</p>
189170

190171
<pre>
191172
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
@@ -221,9 +202,7 @@ to API level 14, you must stop your preview before changing the orientation and
221202
method to take a picture once the preview is started. You can create {@link
222203
android.hardware.Camera.PictureCallback} and {@link
223204
android.hardware.Camera.ShutterCallback} objects and pass them into {@link
224-
android.hardware.Camera#takePicture Camera.takePicture()}. Since the Android
225-
Camera application already does a great job capturing JPEG images, you should
226-
probably implement the raw-image callback.</p>
205+
android.hardware.Camera#takePicture Camera.takePicture()}.</p>
227206

228207
<p>If you want to grab images continously, you can create a {@link
229208
android.hardware.Camera.PreviewCallback} that implements {@link
@@ -236,8 +215,8 @@ takePicture()}.</p>
236215
<h2 id="TaskRestartPreview">Restart the Preview</h2>
237216

238217
<p>After a picture is taken, you must to restart the preview before the user
239-
can take another picture. In the example, the restart is done by overloading
240-
the shutter button, as shown below.</p>
218+
can take another picture. In this example, the restart is done by overloading
219+
the shutter button.</p>
241220

242221
<pre>
243222
&#64;Override
@@ -302,7 +281,7 @@ private void stopPreviewAndFreeCamera() {
302281
}
303282
</pre>
304283

305-
<p>In the example application, this procedure is also part of the {@code
284+
<p>Earlier in the lesson, this procedure was also part of the {@code
306285
setCamera()} method, so initializing a camera always begins with stopping the
307286
preview.</p>
308287

docs/html/training/camera/index.jd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ next.link=photobasics.html
2828
<h2>Try it out</h2>
2929

3030
<div class="download-box">
31-
<a href="{@docRoot}shareables/training/PhotoIntentActivity.zip" class="button">Download the Intent sample</a>
31+
<a href="{@docRoot}shareables/training/PhotoIntentActivity.zip" class="button">Download the sample</a>
3232
<p class="filename">PhotoIntentActivity.zip</p>
3333
</div>
3434

0 commit comments

Comments
 (0)