How to record audio/voice in background continuously in android?

后端 未结 2 1778
野性不改
野性不改 2020-12-12 16:49

As I want to record audio in background I use service..But I am not able to record the audio in service.

I tried same code in Activity it works for me. but how to do

2条回答
  •  有刺的猬
    2020-12-12 17:13

    For starting the recording in backgroun you can either

    • create a thread and do the recording inside a thread.

    • create a service which will run in background.

    Hope it helps.

    Edit 1

    Thread recordInBackGround= new Thread(new Runnable() {
                        @Override
                        public void run() { 
    //Your recording portion of the code goes here.
    }
    });
    
    recordInBackGround.start();
    

提交回复
热议问题