Android Open Source - compCellScope Burst Mode Activity

From Project

Back to project page compCellScope.


The source code is released under:

MIT License

If you think the Android project compCellScope 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 com.wallerlab.compcellscope;
/*w w w . j a v  a2s.c  om*/
import android.hardware.Camera;
import android.hardware.Camera.CameraInfo;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.FrameLayout;

public class BurstModeActivity extends Activity {
  private AcquireSurfaceView mPreview;
  private Camera mCamera;
  private Button mCapture;
  private int capture_counter, delay;
  protected void onCreate(Bundle savedInstanceState) {
    //set # of images you want and delay between each image
    capture_counter = 5;
    delay = 5000;
    // Get the instance of Camera
        mCamera = getCameraInstance();
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR | ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        // access camera Parameters
        final Camera.Parameters camParams = mCamera.getParameters();
        //set color efects to none

         //set antibanding to none
        if (camParams.getAntibanding() != null) {

        // set white ballance
        if (camParams.getWhiteBalance() != null) {
        // Get camera ID of rear camera
        int cameraId = -1;
        int numberOfCameras = Camera.getNumberOfCameras();
        for (int i = 0; i < numberOfCameras; i++) {
          CameraInfo info = new CameraInfo();
          Camera.getCameraInfo(i, info);
          if (info.facing == CameraInfo.CAMERA_FACING_BACK) {
            //Log.d(TAG, "Camera found");
            cameraId = i;
        Camera.CameraInfo info = new Camera.CameraInfo();
        Camera.getCameraInfo(cameraId, info);
        if (info.canDisableShutterSound) {
        // Create our Preview view and set it as the content of our activity.
        mPreview = new AcquireSurfaceView(this, mCamera);
        FrameLayout preview = (FrameLayout) findViewById(;
        mCapture= (Button) findViewById(;
        mCapture.setOnClickListener(new OnClickListener() {
      public void onClick(View arg0) {
        final Handler handler = new Handler(); Runnable() {
            public void run() {
            Log.d("Burst", "Picture Being Taken");                   
            handler.postDelayed(this, 200);
            if(capture_counter == 0){
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(, menu);
    return true;
    public static Camera getCameraInstance(){
        Camera c = null;
        try {
            c =; // attempt to get a Camera instance
        catch (Exception e){
            // Camera is not available (in use or does not exist)
        return c; // returns null if camera is unavailable

  public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == {
      return true;
    return super.onOptionsItemSelected(item);

Java Source Code List