我正在尝试在Android应用程序中使用振动,但显示的错误是The method getSystemservices(String) undefined for the type
。
这是我使用的代码
Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(300);
我该如何解决这些错误,请帮帮我。谢谢
公共类MyClass {
private void Context mContext;
public MyClass(Context context){
mContext = context;
}
public void someFunction(){
// code
Vibrator v = (Vibrator) mContext.getSystemService(Context.VIBRATOR_SERVICE);
// .. code
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句