how i can Using camera to capture picture programmatically without touch the capture button in android like selfie stick using bluetooth sign.
            Asked
            
        
        
            Active
            
        
            Viewed 9,095 times
        
    0
            
            
        - 
                    1Since you are new I urge you to take the tour from here http://stackoverflow.com/tour so that you can ask better questions, and people would try to help if you put more effort. As per your question, I urge you to read the docs at https://developer.android.com/training/camera/index.html and investigate this question http://stackoverflow.com/questions/5991319/capture-image-from-camera-and-display-in-activity – Semih Yagcioglu May 14 '15 at 11:25
1 Answers
2
            Try something like this:
public void takePictureNoPreview(Context context){
    // open back facing camera by default
    Camera myCamera=Camera.open();
    if(myCamera!=null){
        try{
            //set camera parameters if you want to
            //...
            // here, the unused surface view and holder
            SurfaceView dummy=new SurfaceView(context)
            myCamera.setPreviewDisplay(dummy.getHolder());    
            myCamera.startPreview(); 
            myCamera.takePicture(null, null, getJpegCallback()):
        } finally {
            myCamera.close();
        }      
    } else {
        //booo, failed!
    }
  private PictureCallback getJpegCallback(){
      PictureCallback jpeg=new PictureCallback() {   
          @Override
          public void onPictureTaken(byte[] data, Camera camera) {
              FileOutputStream fos;
              try {
                  fos = new FileOutputStream("test.jpeg");
                  fos.write(data);
                  fos.close();
              }  catch (IOException e) {
                 //do something about it
              }
          }
      };
   }
}
Or try some solutions from this post: Taking pictures with camera on Android programmatically
 
    
    
        Community
        
- 1
- 1
 
    
    
        Gabriella Angelova
        
- 2,985
- 1
- 17
- 30
