Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions AndroidCameraServer/res/values-es/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<string name="app_name">AndroidCameraServer</string>
<string name="menu_settings">Configuración</string>
<string name="error_camera">No se pudo inicializar la cámara</string>

</resources>
2 changes: 1 addition & 1 deletion AndroidCameraServer/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<resources>

<string name="app_name">AndroidCameraServer</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string name="error_camera">Camera couldn\'t be initialized</string>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import android.util.Log;
import android.view.Menu;
import android.widget.FrameLayout;
import android.widget.Toast;

public class MainActivity extends Activity {

Expand Down Expand Up @@ -52,14 +53,6 @@ protected void onCreate(Bundle savedInstanceState) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
/* Provide continuous autofocus if camera does not support it */
autoFocusHandler = new Handler();
/* Get an instance of the default camera */
mCamera = getCameraInstance();
/* We create an instance of CameraPreview to manage the camera */
mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
/* Find the frame that will contain the camera preview */
preview = (FrameLayout) findViewById(R.id.frameLayout);
/* Add view to frame */
preview.addView(mPreview);

/* Initialize ICE, copied from an example */
/**************************************************************************/
Expand Down Expand Up @@ -104,6 +97,8 @@ private void releaseCamera() {
if (mCamera != null) {
/* Disable callbacks */
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
mCamera.lock();
mCamera.release();
mCamera = null;
/* Save the state */
Expand Down Expand Up @@ -178,20 +173,27 @@ public void onStop() {
}

public void onPause() {
super.onPause();
releaseCamera();
preview.removeAllViews();
mPreview = null;
super.onPause();
}

@Override
protected void onResume() {
super.onResume();
/* Create a fresh instance of CameraPreview to manage the camera */
/* Get an instance of the default camera */
mCamera = getCameraInstance();
if (mCamera == null) {
Toast.makeText(getApplicationContext(), R.string.error_camera,
Toast.LENGTH_LONG);
this.finish();
}
/* We create an instance of CameraPreview to manage the camera */
mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
/* Find the frame that will contain the camera preview */
preview = (FrameLayout) findViewById(R.id.frameLayout);
/* Add new view to frame */
/* Add view to frame */
preview.addView(mPreview);
}

Expand Down