有谁知道我将如何唤醒 Wear 屏幕?我正在运行振动 API:
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate( getResources().getInteger( R.integer.vibration_duration ) );
它应该在 2 秒(2000 毫秒)后停止。如果屏幕打开,这很好用,但如果屏幕关闭,则振动将继续,直到屏幕被触摸并唤醒。
编辑:我确实整理了一个快速的技巧,使其与计时器一起工作,但我希望能够以更清洁的方式停止振动。
final Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate( getResources().getInteger( R.integer.vibration_duration ) );
Timer timer = new Timer();
timer.schedule( new TimerTask() {
@Override
public void run() {
v.cancel();
}
}, getResources().getInteger( R.integer.vibration_duration ) );
Reedit:这不是每次都有效,所以是的,能够唤醒屏幕将是最好的选择。我确实通过使用模式而不是直接输入持续时间来让它工作,但我仍然很想知道如何激活屏幕,因为我觉得这可能会在我继续使用这个平台时导致更多问题.
long[] pattern = { 0, getResources().getInteger( R.integer.vibration_duration ) };
v.vibrate( pattern, -1 );