在Android手机的状态栏上显示一个摄像头是否在使用的图标(防止偷拍)

使用下面的接口,看下打开关闭camera是否能得到通知,然后做一个service

CameraManager
AvailabilityCallback

public static abstract class AvailabilityCallback {
607
608        /**
609         * A new camera has become available to use.
610         *
611         * <p>The default implementation of this method does nothing.</p>
612         *
613         * @param cameraId The unique identifier of the new camera.
614         */
615        public void onCameraAvailable(@NonNull String cameraId) {
616            // default empty implementation
617        }
618
619        /**
620         * A previously-available camera has become unavailable for use.
621         *
622         * <p>If an application had an active CameraDevice instance for the
623         * now-disconnected camera, that application will receive a
624         * {@link CameraDevice.StateCallback#onDisconnected disconnection error}.</p>
625         *
626         * <p>The default implementation of this method does nothing.</p>
627         *
628         * @param cameraId The unique identifier of the disconnected camera.
629         */
630        public void onCameraUnavailable(@NonNull String cameraId) {
631            // default empty implementation
632        }
633    }

使用通知管理器来显示UI图标:

//创建一个通知管理器
NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值