Example usage for android.content Intent getStringArrayListExtra

List of usage examples for android.content Intent getStringArrayListExtra

Introduction

In this page you can find the example usage for android.content Intent getStringArrayListExtra.

Prototype

public ArrayList<String> getStringArrayListExtra(String name) 

Source Link

Document

Retrieve extended data from the intent.

Usage

From source file:com.techno.jay.codingcontests.Home.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == MaterialSearchView.REQUEST_VOICE && resultCode == RESULT_OK) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (matches != null && matches.size() > 0) {
            String searchWrd = matches.get(0);
            if (!TextUtils.isEmpty(searchWrd)) {
                searchView.setQuery(searchWrd, false);
            }//from  w  w w.j  av  a 2 s  .  c  o  m
        }

        return;
    }
    if (!bp.handleActivityResult(requestCode, resultCode, data))
        super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.google.sample.cast.refplayer.chatting.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.d(TAG, "~~~~~~~~~~ onActivityResult");
    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
        ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
        if (matches.size() > 0) {
            Log.d(TAG, matches.get(0));/*from   w w  w  . ja va2  s.c  om*/
            sendMessage(matches.get(0));
        }
    }
    super.onActivityResult(requestCode, resultCode, data);
}

From source file:org.geometerplus.android.fbreader.network.NetworkLibraryActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Connection.bindToService(this, new Runnable() {
        public void run() {
            getListView().invalidateViews();
        }//from  w  w w.  j a  v  a 2s .c  o  m
    });
    if (resultCode != RESULT_OK || data == null) {
        return;
    }

    switch (requestCode) {
    case REQUEST_MANAGE_CATALOGS: {
        final ArrayList<String> myIds = data.getStringArrayListExtra(ENABLED_CATALOG_IDS_KEY);
        NetworkLibrary.Instance().setActiveIds(myIds);
        NetworkLibrary.Instance().synchronize();
        break;
    }
    case REQUEST_AUTHORISATION_SCREEN: {
        final CookieStore store = ZLNetworkManager.Instance().cookieStore();
        final Map<String, String> cookies = (Map<String, String>) data.getSerializableExtra(COOKIES_KEY);
        if (cookies == null) {
            break;
        }
        for (Map.Entry<String, String> entry : cookies.entrySet()) {
            final BasicClientCookie2 c = new BasicClientCookie2(entry.getKey(), entry.getValue());
            c.setDomain(data.getData().getHost());
            c.setPath("/");
            final Calendar expire = Calendar.getInstance();
            expire.add(Calendar.YEAR, 1);
            c.setExpiryDate(expire.getTime());
            c.setSecure(true);
            c.setDiscard(false);
            store.addCookie(c);
        }
        final NetworkTree tree = getTreeByKey((FBTree.Key) data.getSerializableExtra(TREE_KEY_KEY));
        new ReloadCatalogAction(this).run(tree);
        break;
    }
    }
}

From source file:org.botlibre.sdk.activity.MicConfiguration.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {

    case 1: {//from   www  .ja  v  a  2  s.  c  o  m
        if (resultCode == RESULT_OK && data != null) {
            setMicIcon(false, false);
            ArrayList<String> text = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            editTextForGoogle.setText(text.get(0));
            txt.setText("Status: Done!");
        }
        break;
    }
    }
}

From source file:org.protocoderrunner.apprunner.AppRunnerActivity.java

/**
 * Handle the results from the recognition activity.
 *///from w w  w.  jav  a 2 s .  c  o  m
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && 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);

        for (String _string : matches) {
            MLog.d(TAG, "" + _string);

        }
        onVoiceRecognitionListener.onNewResult(matches.get(0));

    } else if (requestCode == 22 && resultCode == Activity.RESULT_OK) {
        String result = data.getStringExtra("json");
        mAppRunnerFragment.interp.callJsFunction("onResult", result);
    }

    if (onBluetoothListener != null) {
        onBluetoothListener.onActivityResult(requestCode, resultCode, data);
    }

    super.onActivityResult(requestCode, resultCode, data);
}

From source file:com.eugene.fithealthmaingit.UI.ChooseAddMealTabsFragment.java

/**
 * Set the text based on google voice then implement search
 *///from w w w . j a  va2 s  .  co  m
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == REQ_CODE_SPEECH_INPUT) {
        if (resultCode == Activity.RESULT_OK && null != data) {
            ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            if (SEARCH_VOICE.equals("MANUAL")) {
                manualSearch.setText(result.get(0));
            }
            if (SEARCH_VOICE.equals("FAVORITE")) {
                favSearch.setText(result.get(0));
            }
        }
    }
}

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));//from   w  w  w.  ja  v a 2  s .c  o m
        }
        break;
    }
    default:
        break;
    }
}

From source file:com.kaichaohulian.baocms.activity.BusinessApplyThressActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK) {
        switch (requestCode) {
        case REQUEST_CODE:
            if (data != null) {
                photoUrl = new ArrayList<String>();
                photoUrl = data.getStringArrayListExtra(PhotoPickerActivity.KEY_SELECTED_PHOTOS);
                switch (indexType) {
                case 0:
                    photoArray[0] = photoUrl.get(0);
                    Glide.with(getActivity()).load(photoUrl.get(0)).diskCacheStrategy(DiskCacheStrategy.ALL)
                            .into(apply_img_license);
                    break;
                case 1:
                    photoArray[1] = photoUrl.get(0);
                    Glide.with(getActivity()).load(photoUrl.get(0)).diskCacheStrategy(DiskCacheStrategy.ALL)
                            .into(apply_img_logo);
                    break;
                case 2:
                    photoArray[2] = photoUrl.get(0);
                    Glide.with(getActivity()).load(photoUrl.get(0)).diskCacheStrategy(DiskCacheStrategy.ALL)
                            .into(apply_img_corperate_image);
                    break;
                }/*from   www .ja  v  a  2  s.c  o  m*/
            }
            break;
        }
    }
}

From source file:com.todoroo.astrid.voice.VoiceInputAssistant.java

/**
 * This callback-method has to be called from Fragment.onActivityResult within your fragment
 * with parameters directly on passthru.<br>
 * You can check in your fragment if it was really a RecognizerIntent that was handled here,
 * if so, this method returns true. In this case, you should call super.onActivityResult in your
 * fragment.onActivityResult./*from ww w  .  j  ava 2s .  c  o m*/
 * <p>
 * If this method returns false, then it wasnt a request with a RecognizerIntent, so you can handle
 * these other requests as you need.
 *
 * @param activityRequestCode if this equals the requestCode specified by constructor, then results of voice-recognition
 * @param resultCode
 * @param data
 * @return
 */
public boolean handleActivityResult(int activityRequestCode, int resultCode, Intent data, EditText textField) {
    boolean result = false;
    // handle the result of voice recognition, put it into the textfield
    if (activityRequestCode == this.requestCode) {
        // this was handled here, even if voicerecognition fails for any reason
        // so your program flow wont get chaotic if you dont explicitly state
        // your own requestCodes.
        result = true;
        if (resultCode == Activity.RESULT_OK) {
            // Fill the quickAddBox-view with the string the recognizer thought it could have heard
            ArrayList<String> match = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            // make sure we only do this if there is SomeThing (tm) returned
            if (match != null && match.size() > 0 && match.get(0).length() > 0) {
                String recognizedSpeech = match.get(0);
                recognizedSpeech = recognizedSpeech.substring(0, 1).toUpperCase()
                        + recognizedSpeech.substring(1).toLowerCase();

                if (append)
                    textField.setText((textField.getText() + " " + recognizedSpeech).trim());
                else
                    textField.setText(recognizedSpeech);
            }
        }
    }

    return result;
}

From source file:in.codehex.arrow.MainActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
    case Config.REQUEST_SPEECH_INPUT:
        if (resultCode == RESULT_OK && data != null) {
            ArrayList<String> result = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            if (result.get(0).equalsIgnoreCase("emergency")) {
                String phone = userPreferences.getString(Config.KEY_PREF_PHONE, null);
                String message = "Emergency!\n" + userPreferences.getString(Config.KEY_PREF_NAME, null)
                        + " is at http://maps.google.com/maps?q=" + lat + "," + lng;
                try {
                    SmsManager smsManager = SmsManager.getDefault();
                    smsManager.sendTextMessage(phone, null, message, null, null);
                    textToSpeech.speak("Emergency alert sent!", TextToSpeech.QUEUE_FLUSH, null, null);
                } catch (Exception e) {
                    textToSpeech.speak("Unable to send alert message!", TextToSpeech.QUEUE_FLUSH, null, null);
                }//from www.  j av  a  2  s .  c om
            } else if (isDestinationAvailable) {
                if (result.get(0).equalsIgnoreCase("yes")) {
                    processDirection();
                    isDestinationAvailable = false;
                } else {
                    textToSpeech.speak(getString(R.string.prompt_speech_input_initial),
                            TextToSpeech.QUEUE_FLUSH, null, Config.UTTERANCE_ID_INITIAL);
                    isDestinationAvailable = false;
                }
            } else {
                speakData(result.get(0));
            }
        }
        break;
    case Config.REQUEST_CHECK_TTS:
        if (resultCode != TextToSpeech.Engine.CHECK_VOICE_DATA_PASS) {
            intent = new Intent(TextToSpeech.Engine.ACTION_INSTALL_TTS_DATA);
            startActivity(intent);
        }
        break;
    }
}