【问题标题】:Android - How to achieve vibration pattern without pause/delay?Android - 如何实现无暂停/延迟的振动模式?
【发布时间】:2020-04-07 21:11:33
【问题描述】:

如何在没有暂停或延迟的情况下进行连续振动。我尝试了像 {0, 100, 1000, 300, 200} 这样的自定义模式,但即使我将中断设置为 0,它们也会随着中断而振动。

有没有什么方法或者技巧可以实现,因为我在一个应用https://play.google.com/store/apps/details?id=com.jgdevlabs.vibra看到了连续的pattern,所以,一定有方法可以实现。

请帮助我或分享问题,以便任何人都可以提供帮助:(

【问题讨论】:

    标签: android android-studio android-vibration


    【解决方案1】:

    我相信这样就可以实现连续振动。

    它会根据您的需要振动。

    final Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    
             Timer _timer = new Timer();
    
            _timer.scheduleAtFixedRate(new TimerTask() {
                @Override
                public void run() {
                    if(cancelVibration==true){
                        cancel();
                    }
                    v.vibrate(1000);
                }
            },0, 50);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-25
      • 1970-01-01
      • 1970-01-01
      • 2011-02-14
      • 2012-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多