zoukankan      html  css  js  c++  java
  • Android Sensor

    int TYPE_ACCELEROMETER A constant describing an accelerometer sensor type.
    int TYPE_ALL A constant describing all sensor types.  NexusOne默认为 加速度
    int TYPE_AMBIENT_TEMPERATURE A constant describing an ambient temperature sensor type
    int TYPE_GRAVITY A constant describing a gravity sensor type.
    int TYPE_GYROSCOPE A constant describing a gyroscope sensor type  回转仪?
    int TYPE_LIGHT A constant describing an light sensor type.
    int TYPE_LINEAR_ACCELERATION A constant describing a linear acceleration sensor type.
    int TYPE_MAGNETIC_FIELD A constant describing a magnetic field sensor type.  磁场
    int TYPE_ORIENTATION This constant is deprecated. use SensorManager.getOrientation() instead. 定向(指北针)和角度
    int TYPE_PRESSURE A constant describing a pressure sensor type
    int TYPE_PROXIMITY A constant describing an proximity sensor type.
    int TYPE_RELATIVE_HUMIDITY A constant describing a relative humidity sensor type.
    int TYPE_ROTATION_VECTOR A constant describing a rotation vector sensor type.
    int TYPE_TEMPERATURE This constant is deprecated. use Sensor.TYPE_AMBIENT_TEMPERATURE instead.

    public static float[] getOrientation (float[] R, float[] values)

    Since: API Level 3

    Computes the device's orientation based on the rotation matrix.

    When it returns, the array values is filled with the result:

    • values[0]: azimuth, rotation around the Z axis.
    • values[1]: pitch, rotation around the X axis.
    • values[2]: roll, rotation around the Y axis.

    The reference coordinate-system used is different from the world coordinate-system defined for the rotation matrix:

    • X is defined as the vector product Y.Z (It is tangential to the ground at the device's current location and roughly points West).
    • Y is tangential to the ground at the device's current location and points towards the magnetic North Pole.
    • Z points towards the center of the Earth and is perpendicular to the ground.
    Inverted world coordinate-system diagram.

    All three angles above are in radians and positive in the counter-clockwise direction.

    Parameters
    R rotation matrix see getRotationMatrix(float[], float[], float[], float[]).
    values an array of 3 floats to hold the result.
    Returns
    • The array values passed as argument.
    See Also

    About Gravity Sensor

    If you want to use gravity sensor in activity,you can get it by:

            SensorManager mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
            Sensor mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);

    Noticed that TYPE_GRAVITY maybe TYPE_ACCELERATOR or some others ,i'm not sure.

    After this, create a SensorEventListener to deal with the sensor event.And then register the listener,or unregister it when closed.

    However,if you want to disable the AutoRotate of the device,you should modify the settings.Remeber that,like brightness,all the functions of the device level should be modified in settings.

    The following code is used to disable the auto-rotate of the device:

    Uri uri = android.provider.Settings.System.getUriFor("accelerometer_rotation");
    android.provider.Settings.System.putInt(getContentResolver(), "accelerometer_rotation", 0);
    getContentResolver().notifyChange(uri, null);

    0 is off,1 is on.

    public static final String ACCELEROMETER_ROTATION

    Since: API Level 3

    Control whether the accelerometer will be used to change screen orientation. If 0, it will not be used unless explicitly requested by the application; if 1, it will be used by default unless explicitly disabled by the application.

    Constant Value: "accelerometer_rotation"

    You can see all the items of the settings on:http://developer.android.com/reference/android/provider/Settings.System.html

  • 相关阅读:
    随机森林算法参数调优
    BAYES和朴素BAYES
    阿里云 金融接口 token PHP
    PHP mysql 按时间分组 表格table 跨度 rowspan
    MySql按周,按月,按日分组统计数据
    PHP 获取今日、昨日、本周、上周、本月的等等常用的起始时间戳和结束时间戳的时间处理类
    thinkphp5 tp5 会话控制 session 登录 退出 检查检验登录 判断是否应该跳转到上次url
    微信 模板消息
    php 腾讯 地图 api 计算 坐标 两点 距离 微信 网页 WebService API
    php添加http头禁止浏览器缓存
  • 原文地址:https://www.cnblogs.com/qiengo/p/2546016.html
Copyright © 2011-2022 走看看