且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

振动不适用于通知

更新时间:2022-01-02 23:00:07

这是因为您没有在Notification上声明要振动的Vibrator类。在您的通知构建器中,放置此代码并根据您的选择设置振动的持续时间。

It is because you did not declare the Vibrator class to vibrate on Notification.In your notification builder put this code and set the duration of vibrate based on your choose.

    Vibrator v = (Vibrator) this.context.getSystemService(Context.VIBRATOR_SERVICE);
 // Vibrate for 500 milliseconds
 v.vibrate(500);