Use camera in background

Hello. I want to do a task which is of online exam in which I want to click photos continuously in background until user ends test