Search code examples
javaandroidface-detection

Android Face Detection on the background


I'm making an app where I want to detect user's face without showing it. I use standart android api which is android.hardware.Camera.faceDetection() When front camera sees the face, the phone vibrate. I've already implemented this part and now I need to make this app work on the background, so it shouldn't be preview shown on screen. Is it possible?


Solution

  • The code below is for the Background Worker. You can add your code in doInBackground(). It will execute your all processes in the background. Hope it will help full to you.

    import javax.swing.JOptionPane;
    import javax.swing.SwingWorker;
    
    public class Background extends SwingWorker<Void, Void>{
    
        @Override
        protected void done(){
                //JOptionPane.showMessageDialog(null,"Process Done Successfully...","Successfull",JOptionPane.INFORMATION_MESSAGE);
        }
    
        @Override
        protected Void doInBackground() throws Exception {
            //Write your code here
            return null;    
        }
    }