第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > 在Android手机的状态栏上显示一个摄像头是否在使用的图标(防止偷拍)

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

时间:2022-06-16 01:47:41

相关推荐

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

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

CameraManager

AvailabilityCallback

public static abstract class AvailabilityCallback {607608 /**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 implementation617 }618619 /**620 * A previously-available camera has become unavailable for use.621 *622 * <p>If an application had an active CameraDevice instance for the623 * now-disconnected camera, that application will receive a624 * {@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 implementation632 }633 }

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

//创建一个通知管理器

NotificationManager notificationManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。