5

我编写了一些代码,可以在接到来电时将电话静音。当手机处于振动模式时,我使用以下代码停止手机振动:

Vibrator vib = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
vib.cancel();

虽然它在我的带有 android 2.1 的 Nexus One 上工作,但它似乎并不能阻止带有 android 2.1 的 HTC Desire 手机的振动。有人遇到过这个问题吗?

多伦

4

2 回答 2

0

It seems that the vibration doesn’t stop since the stop vibration code which is attached to an incoming call broadcast receiver is executed in some cases before the vibration start and therefore it seems that the vibration doesn't stop.

The solution for me was to check whether the phone vibrates and if so to turn the vibration off else to turn the vibration mode setting to off which prevent the vibration to start.

于 2010-10-20T07:33:10.097 回答
0

这是 Android 的缺点之一,不同的设备表现不同。您是否尝试过使用vibrate(3000);相当于让设备振动 3 秒,试图取消已启动的服务?

于 2010-07-10T11:56:17.040 回答