Android Open Source - permission-explorer Take Picture Activity From Project Back to project page permission-explorer .
License The source code is released under:
Copyright (C) 2012 Rui Gon?alves and Daniel Cibr?o
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),...
If you think the Android project permission-explorer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package pt.up.fe.ssin.pexplorer.actions;
/ / w w w . j a v a 2 s . c o m
import java.io.IOException;
import pt.up.fe.ssin.pexplorer.R;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.hardware.Camera;
import android.hardware.Camera.Parameters;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.ImageView;
public class TakePictureActivity extends Activity implements
SurfaceHolder.Callback {
private ImageView imageView;
private SurfaceView surfView;
private Bitmap bmp;
private SurfaceHolder surfHolder;
private Camera camera;
private Parameters parameters;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.takepicture);
imageView = (ImageView) findViewById(R.id.picImage);
surfView = (SurfaceView) findViewById(R.id.surfImage);
surfHolder = surfView.getHolder();
surfHolder.addCallback(this );
surfHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
@Override
public void surfaceChanged(SurfaceHolder arg0, int arg1, int arg2, int arg3) {
parameters = camera.getParameters();
camera.setParameters(parameters);
camera.startPreview();
Camera.PictureCallback mCall = new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte [] data, Camera camera) {
if (data != null) {
bmp = BitmapFactory.decodeByteArray(data, 0, data.length);
imageView.setImageBitmap(bmp);
}
}
};
if (bmp == null)
camera.takePicture(null, null, mCall);
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
camera = Camera.open();
try {
camera.setPreviewDisplay(holder);
} catch (IOException exception) {
camera.release();
camera = null;
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
camera.stopPreview();
camera.release();
camera = null;
}
}
Java Source Code List pt.up.fe.ssin.pexplorer.actions.AccessFineLocationAction.java pt.up.fe.ssin.pexplorer.actions.AccessNetworkStateAction.java pt.up.fe.ssin.pexplorer.actions.ChangeWifiStateAction.java pt.up.fe.ssin.pexplorer.actions.GetAccountsAction.java pt.up.fe.ssin.pexplorer.actions.InternetAccessAction.java pt.up.fe.ssin.pexplorer.actions.PhoneCallAction.java pt.up.fe.ssin.pexplorer.actions.ReadCalendarAction.java pt.up.fe.ssin.pexplorer.actions.ReadContactsAction.java pt.up.fe.ssin.pexplorer.actions.ReadPhoneStateAction.java pt.up.fe.ssin.pexplorer.actions.RebootAction.java pt.up.fe.ssin.pexplorer.actions.RetrieveRunningTasksAction.java pt.up.fe.ssin.pexplorer.actions.SendTestSmsAction.java pt.up.fe.ssin.pexplorer.actions.ShellCommandAction.java pt.up.fe.ssin.pexplorer.actions.TakePictureAction.java pt.up.fe.ssin.pexplorer.actions.TakePictureActivity.java pt.up.fe.ssin.pexplorer.actions.VibrateAction.java pt.up.fe.ssin.pexplorer.actions.WriteCalendarAction.java pt.up.fe.ssin.pexplorer.actions.WriteExternalStorageAction.java pt.up.fe.ssin.pexplorer.actions.WriteSettingsAction.java pt.up.fe.ssin.pexplorer.app.ActionRegistry.java pt.up.fe.ssin.pexplorer.app.ApplicationListAdapter.java pt.up.fe.ssin.pexplorer.app.FilterConfigActivity.java pt.up.fe.ssin.pexplorer.app.Keys.java pt.up.fe.ssin.pexplorer.app.PermissionAction.java pt.up.fe.ssin.pexplorer.app.PermissionExplorerActivity.java pt.up.fe.ssin.pexplorer.app.PermissionInfoActivity.java pt.up.fe.ssin.pexplorer.app.PermissionListAdapter.java pt.up.fe.ssin.pexplorer.data.GlobalSchema.java pt.up.fe.ssin.pexplorer.data.PermissionCatalog.java pt.up.fe.ssin.pexplorer.data.PermissionDBOperations.java pt.up.fe.ssin.pexplorer.data.PermissionExplorerContentProvider.java pt.up.fe.ssin.pexplorer.entities.Contact.java pt.up.fe.ssin.pexplorer.utils.ApplicationDetailsHelper.java pt.up.fe.ssin.pexplorer.utils.Pair.java pt.up.fe.ssin.pexplorer.utils.PermissionUtils.java pt.up.fe.ssin.pexplorer.utils.ui.AlertDialogHelper.java pt.up.fe.ssin.pexplorer.utils.ui.CheckedLinearLayout.java pt.up.fe.ssin.pexplorer.utils.ui.CheckedRelativeLayout.java pt.up.fe.ssin.pexplorer.utils.ui.FilterTextWatcher.java pt.up.fe.ssin.pexplorer.utils.ui.InputDialogBuilder.java pt.up.fe.ssin.pexplorer.utils.ui.SimpleObjectAdapter.java pt.up.fe.ssin.pexplorer.utils.ui.views.NonEventBlockingScrollView.java