public class MyBroadcastReceiver extends BroadcastReceiver{
public void onReceive(Context context , Intent intent){
Toast.makeText(context, "Your time is up", Toast.LENGTH_LONG).show();
Vibrator vibrator;
// ERROR here (vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
vibrator.vibrate(2000);
}
}
使用警报器时,使用广播接收器振动设备时,会出现如上所示的错误。此处错误的可能原因是什么?
最佳答案
尝试这个
Vibrator v;
v=(Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);
v.vibrate(3000);