Adding Voice Capabilities _ Android Developers.pdf

Embed Size (px)

Citation preview

  • 7/25/2019 Adding Voice Capabilities _ Android Developers.pdf

    1/8

    navigation

    Develop Training Building Apps for Wearables Creating Wearable Apps

    Declare System-provided Voice

    ActionsDeclare App-provided Voice Actions

    Obtaining Free-form Speech Input

    Android Wear Design Principles

    https://developer.android.com/training/wearables/apps/packaging.htmlhttps://developer.android.com/training/wearables/apps/packaging.htmlhttps://developer.android.com/design/wear/index.htmlhttps://developer.android.com/training/wearables/apps/packaging.htmlhttps://developer.android.com/training/wearables/apps/always-on.htmlhttps://developer.android.com/training/wearables/apps/index.htmlhttps://developer.android.com/training/building-wearables.htmlhttps://developer.android.com/training/index.htmlhttps://developer.android.com/develop/index.html
  • 7/25/2019 Adding Voice Capabilities _ Android Developers.pdf

    2/8

    finish()

    MyNoteActivity

    Name Example Phrases Intent

    com.google.android.gms.actions.RESERVE_TAXI_RESERVATION

    android.intent.action.SEND

    com.google.android.voicesearch.SELF_NOTE

    https://developer.android.com/reference/android/app/Activity.html#finish()
  • 7/25/2019 Adding Voice Capabilities _ Android Developers.pdf

    3/8

    android.content.Intent.EXTRA_TEXT

    android.intent.action.SET_ALARM

    android.provider.AlarmClock.EXTRA_HOUR

    android.provider.AlarmClock.EXTRA_MINUTES

    android.intent.action.SET_TIMER

    android.provider.AlarmClock.EXTRA_LENGTH

    com.google.android.wearable.action.STOPWATCH

  • 7/25/2019 Adding Voice Capabilities _ Android Developers.pdf

    4/8

    vnd.google.fitness.TRACK

    vnd.google.fitness.activity/biking

    actionStatus ActiveActionStatus

    CompletedActionStatus

    vnd.google.fitness.TRACK

    vnd.google.fitness.activity/running

    actionStatus ActiveActionStatus

    CompletedActionStatus

    vnd.google.fitness.TRACK

  • 7/25/2019 Adding Voice Capabilities _ Android Developers.pdf

    5/8

    vnd.google.fitness.activity/other

    actionStatus ActiveActionStatus

    CompletedActionStatus

    vnd.google.fitness.VIEW

    vnd.google.fitness.data_type/com.google.heart_rate.bpm

    vnd.google.fitness.VIEW

    vnd.google.fitness.data_type/com.google.step_count.cumulative

    Common intents

    https://developer.android.com/guide/components/intents-common.html
  • 7/25/2019 Adding Voice Capabilities _ Android Developers.pdf

    6/8

    label

    StartRunActivity

    startActivityForResult() ACTION_RECOGNIZE_SPEECH

    onActivityResult()

    privatestaticfinalintSPEECH_REQUEST_CODE =0;

    // Create an intent that can start the Speech Recognizer activity

    privatevoiddisplaySpeechRecognizer(){

    Intentintent =newIntent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);

    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,

    RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);

    // Start the activity, the intent will be populated with the speech text

    startActivityForResult(intent,SPEECH_REQUEST_CODE);

    }

    https://developer.android.com/reference/android/app/Activity.html#onActivityResult(int,%20int,%20android.content.Intent)https://developer.android.com/reference/android/speech/RecognizerIntent.html#ACTION_RECOGNIZE_SPEECHhttps://developer.android.com/reference/android/app/Activity.html#startActivityForResult(android.content.Intent,%20int)
  • 7/25/2019 Adding Voice Capabilities _ Android Developers.pdf

    7/8

    // This callback is invoked when the Speech Recognizer returns.

    // This is where you process the intent and extract the speech text from the intent.

    @Override

    protectedvoidonActivityResult(intrequestCode,intresultCode,

    Intentdata){

    if(requestCode ==SPEECH_REQUEST_CODE &&resultCode ==RESULT_OK){

    Listresults =data.getStringArrayListExtra(

    RecognizerIntent.EXTRA_RESULTS);

    StringspokenText =results.get(0);// Do something with spokenText

    }

    super.onActivityResult(requestCode,resultCode,data);

    }

    Keeping Your App Visible Packaging Wearable Apps

    Except as noted, this content is licensed under Creative Commons Attribution 2.5. For details and restrictions, see the Content License.

    Get news & tips Blog Support

    Developers DEVELOP Search

    https://developer.android.com/distribute/index.htmlhttps://developer.android.com/develop/index.htmlhttps://developer.android.com/design/index.htmlhttps://developer.android.com/training/wearables/apps/voice.htmlhttps://developer.android.com/index.htmlhttps://twitter.com/AndroidDevhttps://plus.google.com/+AndroidDevelopershttps://www.youtube.com/user/androiddevelopershttps://developer.android.com/support.htmlhttp://android-developers.blogspot.com/https://developer.android.com/license.htmlhttp://creativecommons.org/licenses/by/2.5/https://developer.android.com/training/wearables/apps/packaging.htmlhttps://developer.android.com/training/wearables/apps/always-on.html
  • 7/25/2019 Adding Voice Capabilities _ Android Developers.pdf

    8/8

    About Android | Auto | TV | Wear | Legal English

    https://developer.android.com/legal.htmlhttps://developer.android.com/wear/index.htmlhttps://developer.android.com/tv/index.htmlhttps://developer.android.com/auto/index.htmlhttps://developer.android.com/about/android.html