com.awareframework.ios.sensor.screen 0.5.0

com.awareframework.ios.sensor.screen 0.5.0

tetujinyuuki.nishiyama 维护。



  • Yuuki Nishiyama

AWARE: 屏幕

CI Status Version License Platform

屏幕传感器监测屏幕状态,如开关、锁定和解锁。

要求

iOS 10 或更高版本

安装

com.awareframework.ios.sensor.wifi 通过 CocoaPods 提供。

  1. 要安装它,只需将以下行添加到 Podfile 中
pod 'com.awareframework.ios.sensor.screen'
  1. 将 com.awareframework.ios.sensor.screen 库导入到您的源代码中。
import com_awareframework_ios_sensor_screen

ScreenSensor

  • init(config:ScreenSensor.Config?) : 使用可选配置初始化屏幕传感器。
  • start(): 开始使用可选配置运行陀螺仪传感器。
  • stop(): 停止服务。

ScreenSensor.Config

用于存储传感器配置的类。

Fields

  • sensorObserver: ScreenObserver:实时数据更新的回调。
  • enabled: Boolean 传感器是否启用。 (默认 = false)
  • debug: Boolean 启用/禁用向 Logcat 记录日志。 (默认 = false)
  • label: String 数据的标签。 (默认 = "")
  • deviceId: String 与事件和传感器相关联的设备的ID。 (默认 = "")
  • dbEncryptionKey 数据库的加密密钥。 (默认 = null)
  • dbType: Engine 用于保存数据的数据库引擎。 (默认 = Engine.DatabaseType.NONE)
  • dbPath: String 数据库路径。 (默认 = "aware_screen")
  • dbHost: String 同步数据库的主机。 (默认 = null)

Broadcasts

  • ScreenSensor.ACTION_AWARE_SCREEN_ON 屏幕开启时触发。
  • ScreenSensor.ACTION_AWARE_SCREEN_OFF 屏幕关闭时触发。
  • ScreenSensor.ACTION_AWARE_SCREEN_LOCKED 屏幕锁定时触发。
  • ScreenSensor.ACTION_AWARE_SCREEN_UNLOCKED 屏幕解锁时触发。

Data Representations

Screen Data

包含屏幕配置文件。

字段 类型 描述
screenStatus Int 屏幕状态,以下之一:0=关闭,1=开启,2=锁定,3=解锁
设备ID 字符串 AWARE设备UUID
标签 字符串 可自定义的标签。对于数据校准或追踪很有用
时间戳 长整型 自1970年起的Unix毫秒时间戳
时区 Int 设备的时区
操作系统 字符串 设备的操作系统(例如,iOS)

示例用法

var screenSensor = ScreenSensor.init(ScreenSensor.Config().apply{config in
    config.sensorObserver = Observer()
    config.debug = true
    config.dbType = .REALM
})
screenSensor?.start()
class Observer:ScreenObserver{
    func onScreenOn() {
        // Your code here ...
    }

    func onScreenOff() {
        // Your code here ...
    }

    func onScreenLocked() {
        // Your code here ...
    }

    func onScreenUnlocked() {
        // Your code here ...
    }
}

作者

tetujin,[email protected]

许可协议

版权(c)2018 AWARE移动上下文仪表化中间件/框架(http://www.awareframework.com

根据Apache许可证版本2.0("许可证");除非遵守许可证规定,否则不得使用此文件。您可以在此处获得许可证副本:

https://apache.ac.cn/licenses/LICENSE-2.0 除非适用法律要求或以书面形式同意,否则根据许可证分发的软件按"现状"提供,不提供任何明示或暗示的保证或条件。有关许可证的具体语言管理许可和限制,请参阅许可证。