마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

vibrate를 다른 클래스에서 사용할려고 객체로 생성했는데 오류가 납니다

0 추천
다른 클래스에서 밑의 문장에 오류가 납니다 뭘 잘못 한것일까요 ㅠㅜ?

VibratorExample m_vibrator = new VibratorExample(); 오류가 나서 못 받아옵니다 ㅠㅜ

 

 

 

VibratorExample 클래스 입니다 밑에는

public class VibratorExample extends View {
 Vibrator m_vibrator = null;
 public VibratorExample(Context context) {
  super(context);
  m_vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
  
 }
 
 public void toctoc(int ms){
  m_vibrator.vibrate(ms); // 0.1초 진동한다.
  
 }
  
}
익명사용자 님이 2015년 12월 20일 질문

1개의 답변

0 추천

VibratorExample m_vibrator = new VibratorExample(getApplicationContext());

익명사용자 님이 2015년 12월 21일 답변
...