Skip to content

Instantly share code, notes, and snippets.

@fevziomurtekin
Created January 25, 2019 11:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fevziomurtekin/afe05abb9903aea2e98b537c5ca81f8f to your computer and use it in GitHub Desktop.
Save fevziomurtekin/afe05abb9903aea2e98b537c5ca81f8f to your computer and use it in GitHub Desktop.
private fun sendMicrophoneMessage(view:View){
val intent: Intent = 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,
getString(R.string.speech_prompt)
)
try {
startActivityForResult(intent, SPEECH_INPUT)
} catch (a: ActivityNotFoundException) {
Toast.makeText(
applicationContext,
getString(R.string.speech_not_supported),
Toast.LENGTH_SHORT
).show()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment