我想从 View 类中获取 Vibrator
服务。这可能吗?
我试过添加这个...
Vibrator vib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);
... 但是 VIBRATOR_SERVICE
上有错误 - 它无法解析为变量。将上下文设置为 getApplicationContext()
也无济于事。
最佳答案
感谢@Luksprog 在评论中的回答。
Vivrator vib = (Vibrator) getContext().getSystemService(Context.VIBRATOR_SERVICE);
关于android - 在自定义 View 中实现振动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19617821/