List of usage examples for android.speech RecognizerIntent EXTRA_RESULTS
String EXTRA_RESULTS
To view the source code for android.speech RecognizerIntent EXTRA_RESULTS.
Click Source Link
From source file:com.example.swipeuiforupclose.MainActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == RESULT_OK && null != data && requestCode == REQUEST_CODE) { ArrayList<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); Toast.makeText(getApplicationContext(), "Great Job !", Toast.LENGTH_SHORT).show(); EditText et = (EditText) findViewById(R.id.et_about_me_text); et.setText(text.get(0));/*from www . jav a 2 s .c o m*/ } }
From source file:com.ola.insta.BookingAcivity.java
/** * Receiving speech input/*from w w w . j a v a 2s . c o m*/ * */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK && null != data) { switch (requestCode) { case REQ_CODE_SPEECH_INPUT: ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); boolean isMatched = false; for (String string : result) { if (string.contains(Constants.VOICE_MESSAGE)) { /* * Toast.makeText( getApplicationContext(), * getApplicationContext().getString( * R.string.cab_booked), Toast.LENGTH_SHORT).show(); */ // Call REST API if (Utilities.isNetworkAvailable(this)) { new GetCabBookingRequestTask().execute(); } else { Utilities mUltilities = new Utilities(); mUltilities.showDialogConfirm(BookingAcivity.this, "Message", "Please check network connection", true).show(); } isMatched = true; break; } } if (!isMatched) { speakOut("Please try again!"); Toast.makeText(getApplicationContext(), getApplicationContext().getString(R.string.speech_try_again), Toast.LENGTH_SHORT) .show(); } break; case REQ_CODE_SELECT_CONTACT: Uri uri = data.getData(); String id = uri.getLastPathSegment(); Cursor contact = getContentResolver().query(Phone.CONTENT_URI, null, Phone.CONTACT_ID + "=?", new String[] { id }, null); if (contact.moveToFirst()) { if (contact.getString(contact.getColumnIndex(Phone.HAS_PHONE_NUMBER)) != null) { final String contactName = contact.getString(contact.getColumnIndex(Phone.DISPLAY_NAME)); final String phoneNum = contact.getString(contact.getColumnIndex(Phone.NUMBER)); MaterialDialog dialog = new MaterialDialog(context, context.getString(R.string.emergency_contact), "Name : " + contactName + "\nNumber : " + phoneNum, context.getString(R.string.add), context.getString(R.string.cancel)); dialog.setOnAcceptButtonClickListener(new OnClickListener() { @Override public void onClick(View v) { saveToShrPref(contactName, phoneNum); Toast.makeText(context, "Emergency contact saved successfully!", Toast.LENGTH_LONG) .show(); } }); dialog.setOnCancelButtonClickListener(new OnClickListener() { @Override public void onClick(View v) { } }); dialog.show(); } else Toast.makeText(context, context.getString(R.string.contact_dont_have_number), Toast.LENGTH_LONG).show(); } break; default: break; } } }
From source file:net.olejon.mdapp.NasjonaleRetningslinjerActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == VOICE_SEARCH_REQUEST_CODE && data != null) { ArrayList<String> voiceSearchArrayList = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); String voiceSearchString = voiceSearchArrayList.get(0); search(voiceSearchString);/* w ww .ja v a2 s. c om*/ } }
From source file:com.tdispatch.passenger.fragment.SearchAddressFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if ((requestCode == Const.RequestCode.VOICE_RECOGNITION) && (resultCode == Activity.RESULT_OK)) { ArrayList<String> matches = intent.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); WebnetLog.d("size: " + matches.size()); if (matches.size() > 0) { WebnetLog.d("1st: " + matches.get(0)); EditText et = (EditText) mFragmentView.findViewById(R.id.address); et.setText(matches.get(0));/*ww w. j av a2s. c o m*/ } } }
From source file:com.jaspersoft.android.jaspermobile.activities.library.LibraryPageFragment.java
@OnActivityResult(VOICE_COMMAND) final void voiceCommandAction(int resultCode, Intent data) { if (resultCode != Activity.RESULT_OK) return;/*ww w . java 2s . c om*/ ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (libraryControllerFragment != null) { libraryControllerFragment.handleVoiceCommand(matches); } }
From source file:hackathon.openrice.CardsActivity.java
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); Bundle extras = getIntent().getExtras(); String keyword = null;//from w ww. j a v a2s. c o m if (extras != null) { ArrayList<String> text = extras.getStringArrayList(RecognizerIntent.EXTRA_RESULTS); if (text != null) { for (String t : text) { String temp = t.toLowerCase().trim(); if (temp.startsWith("search")) { keyword = temp.substring(6).trim(); } } } } Card info = new Card(this); info.setText("Loading data..."); cards.add(info); RetrieveImage task = new RetrieveImage(); // listener passed over to locationProvider, any location update is handled here this.locationListener = new LocationListener() { @Override public void onStatusChanged(String provider, int status, Bundle extras) { } @Override public void onProviderEnabled(String provider) { } @Override public void onProviderDisabled(String provider) { } @Override public void onLocationChanged(final Location location) { // forward location updates fired by LocationProvider to architectView, you can set lat/lon from any location-strategy if (location != null) { // sore last location as member, in case it is needed somewhere (in e.g. your adjusted project) lastKnownLocation = location; if (lastKnownLocation != null) { // check if location has altitude at certain accuracy level & call right architect method (the one with altitude information) if (location.hasAltitude() && location.hasAccuracy() && location.getAccuracy() < 7) { lastKnownLocation = location; } else { lastKnownLocation = location; } } } } }; locationProvider = new LocationProvider(this, locationListener); double x, y; if (lastKnownLocation != null) { x = lastKnownLocation.getLatitude(); y = lastKnownLocation.getLongitude(); } else { x = 22.3049989; y = 114.17925600000001; } if (keyword != null) { //Log.d("FFFF", keyword); task.execute( "http://openricescraper.herokuapp.com/?x=" + x + "&y=" + y + "&keyword=" + Uri.encode(keyword)); } else { task.execute("http://openricescraper.herokuapp.com/?x=" + x + "&y=" + y); } mCardScroller = new CardScrollView(this); mCardScroller.setAdapter(new CardAdapter(cards)); mCardScroller.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) { final String className = "com.wikitude.samples.SampleCamActivity"; try { final Intent intent = new Intent(ctx, Class.forName(className)); intent.putExtra(EXTRAS_KEY_ACTIVITY_TITLE_STRING, "5.2 Adding Radar"); intent.putExtra(EXTRAS_KEY_ACTIVITY_ARCHITECT_WORLD_URL, "samples/5_Browsing$Pois_2_Adding$Radar/index.html"); if (poiData != null) { JSONArray pass = new JSONArray(); final String ATTR_ID = "id"; final String ATTR_NAME = "name"; final String ATTR_DESCRIPTION = "description"; final String ATTR_LATITUDE = "latitude"; final String ATTR_LONGITUDE = "longitude"; final String ATTR_ALTITUDE = "altitude"; int i = position - 1; //for (int i = 0; i < poiData.length(); i++) { JSONObject jsonObj = (JSONObject) poiData.get(i); final HashMap<String, String> poiInformation = new HashMap<String, String>(); poiInformation.put(ATTR_ID, String.valueOf(i)); poiInformation.put(ATTR_NAME, new String(jsonObj.getString("name").getBytes("ISO-8859-1"), "UTF-8")); if (jsonObj.getString("score").equalsIgnoreCase("null")) { poiInformation.put(ATTR_DESCRIPTION, new String(jsonObj.getString("address").getBytes("ISO-8859-1"), "UTF-8")); } else { poiInformation.put(ATTR_DESCRIPTION, "" + jsonObj.getDouble("score") + ", " + new String(jsonObj.getString("address").getBytes("ISO-8859-1"), "UTF-8")); } poiInformation.put(ATTR_LATITUDE, String.valueOf(jsonObj.get("x"))); poiInformation.put(ATTR_LONGITUDE, String.valueOf(jsonObj.get("y"))); final float UNKNOWN_ALTITUDE = -32768f; // equals "AR.CONST.UNKNOWN_ALTITUDE" in JavaScript (compare AR.GeoLocation specification) // Use "AR.CONST.UNKNOWN_ALTITUDE" to tell ARchitect that altitude of places should be on user level. Be aware to handle altitude properly in locationManager in case you use valid POI altitude value (e.g. pass altitude only if GPS accuracy is <7m). poiInformation.put(ATTR_ALTITUDE, String.valueOf(UNKNOWN_ALTITUDE)); pass.put(new JSONObject(poiInformation)); //} intent.putExtra("poiData", pass.toString()); } /* launch activity */ ctx.startActivity(intent); } catch (Exception e) { /* * may never occur, as long as all SampleActivities exist and are * listed in manifest */ Toast.makeText(ctx, className + "\nnot defined/accessible", Toast.LENGTH_SHORT).show(); } } }); setContentView(mCardScroller); IntentFilter filter = new IntentFilter(); filter.addAction("com.ours.asyncisover"); filter.addCategory("android.intent.category.DEFAULT"); registerReceiver(myBroadcastReceiver, filter); isReceiverRegistered = true; }
From source file:com.surveyorexpert.TalkToMe.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == SPEECH_REQUEST_CODE) { if (resultCode == RESULT_OK) { ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); if (matches.size() == 0) { tts.speak("Heard nothing", TextToSpeech.QUEUE_FLUSH, null); } else { String mostLikelyThingHeard = matches.get(0); String magicWord = this.getResources().getString(R.string.magicword); if (mostLikelyThingHeard.equals(magicWord)) { tts.speak("You said the magic word!", TextToSpeech.QUEUE_FLUSH, null); } else { // tts.speak("Recognised " + mostLikelyThingHeard + " Is that OK", TextToSpeech.QUEUE_FLUSH, null); gotMessage = mostLikelyThingHeard; tts.speak(gotMessage + " OK?", TextToSpeech.QUEUE_FLUSH, null); //intent.putExtra("description",mostLikelyThingHeard); }/*w ww. j ava 2 s . com*/ } result.setText("heard: " + matches); // Toast.makeText(getBaseContext(),"TalkToMe Done " + gotMessage, Toast.LENGTH_LONG).show(); } else { Log.d(TAG, "result NOT ok"); } } super.onActivityResult(requestCode, resultCode, data); }
From source file:org.apache.cordova.nodialogspeechrecognizer.SpeechRecognizer.java
/** * Handle the results from the recognition activity. *//*w w w. jav a 2s . c o m*/ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (resultCode == Activity.RESULT_OK) { // Fill the list view with the strings the recognizer thought it could // have heard ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); returnSpeechResults(matches); } else { // Failure - Let the caller know this.callbackContext.error(Integer.toString(resultCode)); } super.onActivityResult(requestCode, resultCode, data); }
From source file:me.tylerbwong.pokebase.gui.fragments.PokebaseFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == RECOGNIZER_REQ_CODE && data != null) { searchInput.setText(data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS).get(0)); refreshData();/*from w w w . j a v a 2 s. c om*/ } }
From source file:org.alfresco.mobile.android.application.fragments.search.SearchFragment.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch (requestCode) { case RequestCode.TEXT_TO_SPEECH: { if (resultCode == FragmentActivity.RESULT_OK && data != null) { ArrayList<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS); searchForm.setText(text.get(0)); search(text.get(0));// w w w . ja v a 2s. c o m } break; } default: break; } }