简体   繁体   中英

Take a picture on background service android (Camera and Camera2)

我想每分钟拍照而不开始相机活动并将其保存在设备存储器上,如何在后台服务上启动和使用相机...

You can extend Service Make connection to camera You can make Tier that will make photo from some time.

    public class CameraPhoto extends Service {

        @Override
        public void onCreate() {
            super.onCreate();
            Timer timer = new Timer();
            timer.schedule(new UpdateTimeTask(), 0, 1800000); //тикаем каждые 30 мinute без задержки 
        }
        //задача для таймера

        class UpdateTimeTask extends TimerTask {
            public void run() {
//Here write what you want do . You can call method here, or make manipulation with camera
                }
            }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM