【问题标题】:Android Vibrate Service (Vibrator) is not working for long timeAndroid 振动服务(振动器)长时间不工作
【发布时间】:2013-06-13 04:05:04
【问题描述】:

我想长时间振动手机(例如 2 分钟),但它振动的时间很短。 我正在使用此代码

Vibrator mVibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
mVibrate.vibrate(2*60*1000); // 2 Minutes

如何振动 2 或 3 分钟?

【问题讨论】:

    标签: android android-vibration system-setting


    【解决方案1】:

    还有另外一种长振动方式,

    Vibrator mVibrate = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    long pattern[]={0,800,200,1200,300,2000,400,4000};
    // 2nd argument is for repetition pass -1 if you do not want to repeat the Vibrate
    mVibrate.vibrate(pattern,-1);
    

    您可以增加图案的阵列以进行长时间振动。

    【讨论】:

    • 如果我通过 10(重复 10 次)代替 -1,则振动不会重复 10 次。如何重复?
    • @AtulBhardwaj 您正在测试哪个设备?
    • 我正在使用 Htc one v (ICS)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 1970-01-01
    • 1970-01-01
    • 2012-02-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多