移动开发

Android 如何定制vibrator的各种震动模式M 具体方法

2020-11-06 18:12:02 阅读数 2337 收藏 0
一般振动时间的配置在如下文件:
复制代码 代码如下:

frameworks/base/core/res/res/values/config.xml
    <!-- 长按振动 -->
    <!-- Vibrator pattern for feedback about a long screen/key press -->
    <integer-array name="config_longPressVibePattern">
        <item>0</item>
        <item>1</item>
        <item>20</item>
        <item>21</item>
    </integer-array>

    <!-- 虚拟按键振动 -->
    <!-- Vibrator pattern for feedback about touching a virtual key -->
    <integer-array name="config_virtualKeyVibePattern">
        <item>0</item>
        <item>10</item>
        <item>20</item>
        <item>30</item>
    </integer-array>

    <!-- 软键盘按键振动 -->
    <!-- Vibrator pattern for a very short but reliable vibration for soft keyboard tap -->
    <integer-array name="config_keyboardTapVibePattern">
        <item>40</item>
    </integer-array>

    <!-- 非安全模式启动振动 -->
    <!-- Vibrator pattern for feedback about booting with safe mode disabled -->
    <integer-array name="config_safeModeDisabledVibePattern">
        <item>0</item>
        <item>1</item>
        <item>20</item>
        <item>21</item>
    </integer-array>

    <!-- 安全模式启动振动 -->
    <!-- Vibrator pattern for feedback about booting with safe mode disabled -->
    <integer-array name="config_safeModeEnabledVibePattern">
        <item>0</item>
        <item>1</item>
        <item>20</item>
        <item>21</item>
        <item>500</item>
        <item>600</item>
    </integer-array>

上面以数组形式的表示的,奇数位置表示暂停时间,偶数位置表示振动时间,单位为 ms