intent 함수에서 putExtra가 없다고 하네요....(android studio)
조회수 812회
Intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); Intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); Intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Hi speak something"); 이라는 코드를 사용한 결과 putExtra에 빨간 밑줄이 그어지며 각각 아래의 오류 표시가 떴습니다.
non-static method putExtra(String,String) cannot be referenced from a static context non-static method putExtra(String,Serializable) cannot be referenced from a static context non-static method putExtra(String,String) cannot be referenced from a static context
그래서 다시 써보니 보통 put- 이렇게 쓰다보면 아래 다양하게 함수들이 나와야하는데 애시당초 없다는 듯이 뜨는 것이 없습니다.
이제 처음 받고 만들어본 건데 함수를 따로 다운 받아야하는 건가요? 아니면 다른 문제가 있는 건가요?
-
(•́ ✖ •̀)
알 수 없는 사용자
1 답변
-
Intent i = new Intent(); i.putExtra(...)
인스턴스를 만들어 사용하시기 바랍니다.
질문 작성자입니다. 어떻게 답변에 대한 추가 질문을 올려야 할지 몰라 이곳에 올립니다.
private void speak() {
Intent intent = new Intent (RecognizerIntent.ACTION_RECOGNIZE_SPEECH); Intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); Intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault()); Intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Hi speak something"); //start intent try { // in there was no error startActivityForResult(intent, REQUEST_CODE_SPEECH_INPUT); } catch (Exception e) { //if there was some error //get message of error and show Toast.makeText(this,""+e.getMessage(), Toast.LENGTH_SHORT).show(); } }
이렇게 이미 new를 해준 것이 있는 상태에서 에러가 났습니다.ㅠㅠ
댓글 입력