Example usage for android.os Bundle getStringArrayList

List of usage examples for android.os Bundle getStringArrayList

Introduction

In this page you can find the example usage for android.os Bundle getStringArrayList.

Prototype

@Override
@Nullable
public ArrayList<String> getStringArrayList(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.baidu.android.voicedemo.ApiActivity.java

@Override
public void onResults(Bundle results) {
    long end2finish = System.currentTimeMillis() - speechEndTime;
    status = STATUS_None;//from  ww w. j a va 2s  .  co m
    ArrayList<String> nbest = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    print("?" + Arrays.toString(nbest.toArray(new String[nbest.size()])));
    String json_res = results.getString("origin_result");
    try {
        print("origin_result=\n" + new JSONObject(json_res).toString(4));
    } catch (Exception e) {
        print("origin_result=[warning: bad json]\n" + json_res);
    }
    btn.setText("");
    String strEnd2Finish = "";
    if (end2finish < 60 * 1000) {
        strEnd2Finish = "(waited " + end2finish + "ms)";
    }
    txtResult.setText(nbest.get(0) + strEnd2Finish);
}

From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java

@Override
public void onPartialResults(Bundle partialResults) {
    ArrayList<String> nbest = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if (nbest.size() > 0) {
        Log.i(TAG, "onPartialResults----> " + nbest.get(0));
        String result = nbest.get(0);
        mResultText.setText(result);/* w  w  w  . j  a  va2s . co m*/
    }
}

From source file:ai.api.unityhelper.RecognitionHelper.java

protected void onResults(final Bundle results) {

    JSONObject resultJson = new JSONObject();

    try {// ww w .  j av a 2s.  c o m

        resultJson.put("status", "success");

        final ArrayList<String> recognitionResults = results
                .getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);

        if (recognitionResults == null || recognitionResults.size() == 0) {
            resultJson.put("recognitionResults", new JSONArray());
        } else {
            resultJson.put("recognitionResults", new JSONArray(recognitionResults));

            float[] rates = null;

            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                rates = results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES);
                if (rates != null && rates.length > 0) {
                    final JSONArray ratesArray = new JSONArray();
                    for (int i = 0; i < rates.length; i++) {
                        ratesArray.put(rates[i]);
                    }
                    resultJson.put("confidence", ratesArray);
                }
            }
        }

    } catch (JSONException je) {
        Log.e(TAG, je.getMessage(), je);
    }

    clearRecognizer();
    String resultJsonString = resultJson.toString();
    if (resultObject != null) {
        resultObject.setResult(resultJsonString);
    }
}

From source file:com.jaspersoft.android.jaspermobile.dialog.SaveReportOptionDialogFragment.java

@Override
protected void initDialogParams() {
    super.initDialogParams();

    Bundle args = getArguments();
    if (args != null) {
        if (args.containsKey(CURRENTLY_SELECTED_ARG)) {
            mCurrentlySelected = args.getInt(CURRENTLY_SELECTED_ARG);
        }//from   w w w . ja v a2 s  .  c o  m
        if (args.containsKey(REPORT_OPTIONS_TITLES_ARG)) {
            mReportOptionsTitles = args.getStringArrayList(REPORT_OPTIONS_TITLES_ARG);
        }
    }
}

From source file:br.fapema.morholt.android.wizardpager.wizard.basic.FixedFragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);//from   ww w.j a  v  a2  s .  c  o m
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();

        ArrayList<String> tags = bundle.getStringArrayList("tags");
        if (tags != null) {
            mSavedFragmentTags = tags;
        } else {
            mSavedFragmentTags.clear();
        }
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:com.webalcove.travelbook.FixedFragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);/*from   w w w. j  a  va2s .  c om*/
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        ArrayList<String> tags = bundle.getStringArrayList("tags");
        if (tags != null) {
            mSavedFragmentTags = tags;
        } else {
            mSavedFragmentTags.clear();
        }
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:in.ac.dtu.subtlenews.InstapaperViewer.java

@SuppressLint("NewApi")
@Override/*from   ww w .  j  a v a2s .c  o  m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        setImmersive(true);
    }
    setTheme(R.style.AppTheme_NoActionBar);

    setContentView(R.layout.activity_instapaper_viewer);
    //setupActionBar();

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        urlId = extras.getInt("URLID");
        urlList = extras.getStringArrayList("URLList");

    }
    final WebView instapaperView = (WebView) findViewById(R.id.instapaper_viewer);
    final Activity activity = this;
    final ProgressBar progressBar;
    progressBar = (ProgressBar) findViewById(R.id.progressBar);

    instapaperView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100 && progressBar.getVisibility() == ProgressBar.GONE) {
                progressBar.setVisibility(ProgressBar.VISIBLE);
                //txtview.setVisibility(View.VISIBLE);
            }
            progressBar.setProgress(progress);
            if (progress == 100) {
                progressBar.setVisibility(ProgressBar.GONE);
                //txtview.setVisibility(View.GONE);
            }
        }
    });

    final View controlsView = findViewById(R.id.fullscreen_content_controls);
    final View contentView = findViewById(R.id.instapaper_viewer);

    final Button prevButton = (Button) findViewById(R.id.summary_prev_button);
    final Button nextButton = (Button) findViewById(R.id.summary_next_button);

    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    mSystemUiHider = SystemUiHider.getInstance(this, contentView, HIDER_FLAGS);
    mSystemUiHider.setup();
    mSystemUiHider.setOnVisibilityChangeListener(new SystemUiHider.OnVisibilityChangeListener() {
        // Cached values.
        int mControlsHeight;
        int mShortAnimTime;

        @Override
        @TargetApi(Build.VERSION_CODES.HONEYCOMB_MR2)
        public void onVisibilityChange(boolean visible) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                // If the ViewPropertyAnimator API is available
                // (Honeycomb MR2 and later), use it to animate the
                // in-layout UI controls at the bottom of the
                // screen.
                if (mControlsHeight == 0) {
                    mControlsHeight = controlsView.getHeight();
                }
                if (mShortAnimTime == 0) {
                    mShortAnimTime = getResources().getInteger(android.R.integer.config_shortAnimTime);
                }
                controlsView.animate().translationY(visible ? 0 : mControlsHeight).setDuration(mShortAnimTime);
            } else {
                // If the ViewPropertyAnimator APIs aren't
                // available, simply show or hide the in-layout UI
                // controls.
                controlsView.setVisibility(visible ? View.VISIBLE : View.GONE);
            }

            if (visible && AUTO_HIDE) {
                // Schedule a hide().
                delayedHide(AUTO_HIDE_DELAY_MILLIS);
            }

        }
    });

    // Set up the user interaction to manually show or hide the system UI.
    contentView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (TOGGLE_ON_CLICK) {
                mSystemUiHider.toggle();
            } else {
                mSystemUiHider.show();
            }
        }
    });

    // Upon interacting with UI controls, delay any scheduled hide()
    // operations to prevent the jarring behavior of controls going away
    // while interacting with the UI.
    prevButton.setOnTouchListener(mDelayHideTouchListener);
    nextButton.setOnTouchListener(mDelayHideTouchListener);

    try {
        summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(urlId);
    } catch (Exception e) {
        e.printStackTrace();
    }

    instapaperView.loadUrl(summaryUrl);
    prevButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(--urlId);
            } catch (Exception e) {
                e.printStackTrace();
            }
            instapaperView.loadUrl(summaryUrl);
        }
    });
    nextButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            try {
                summaryUrl = "http://www.instapaper.com/text?u=" + urlList.get(++urlId);
            } catch (Exception e) {
                e.printStackTrace();
            }
            instapaperView.loadUrl(summaryUrl);
        }
    });

}

From source file:com.subzero.runners.android.AndroidLauncher.java

@Override
public void queryPurchases(Preferences pref) {
    this.pref = pref;
    try {/*  w  ww  . j  a  va 2s . c  om*/
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0) {
            ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

            for (int i = 0; i < ownedSkus.size(); i++) {
                String name = null;

                if (ownedSkus.get(i).equals("ryan"))
                    name = "Ryan";
                else if (ownedSkus.get(i).equals("ash"))
                    name = "Ash";
                else if (ownedSkus.get(i).equals("rob"))
                    name = "Rob";
                else if (ownedSkus.get(i).equals("battle_cat"))
                    name = "BattleCat";
                else if (ownedSkus.get(i).equals("xorp"))
                    name = "Xorp";
                else if (ownedSkus.get(i).equals("rootsworth"))
                    name = "Rootsworth";
                else if (ownedSkus.get(i).equals("snap"))
                    name = "Snap";
                else if (ownedSkus.get(i).equals("metatron"))
                    name = "Metatron";
                else if (ownedSkus.get(i).equals("abaddon"))
                    name = "Abaddon";

                pref.putBoolean(name, true);
                pref.flush();
            }
        }
    } catch (RemoteException e) {
        e.printStackTrace();
    }

}

From source file:us.opcam.camera.activity.URLImagePagerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.discover_image_pager);

    Bundle bundle = getIntent().getExtras();
    assert bundle != null;

    // intent  bundle?  .
    String[] imageUrls = bundle.getStringArray(Extra.IMAGES);
    imagesAuthor = bundle.getStringArrayList(Extra.IMAGES_AUTHOR);
    imagesCreateDate = bundle.getStringArrayList(Extra.IMAGES_CREATE_DATE);
    pagerPosition = bundle.getInt(Extra.IMAGE_POSITION, 0); // ? ? ?

    if (savedInstanceState != null) {
        pagerPosition = savedInstanceState.getInt(STATE_POSITION);
    }/*w  w  w  .  j  a  va  2 s.  c  om*/

    if (imageUrls == null)
        finish();

    options = new DisplayImageOptions.Builder().showImageForEmptyUri(R.drawable.ic_empty)
            .showImageOnFail(R.drawable.ic_error).resetViewBeforeLoading(true).cacheOnDisk(true)
            .imageScaleType(ImageScaleType.EXACTLY).bitmapConfig(Bitmap.Config.RGB_565).considerExifParams(true)
            .displayer(new FadeInBitmapDisplayer(300)).build();

    // ?  ? pager? ?  ?? .
    pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(new ImagePagerAdapter(imageUrls, imagesAuthor, imagesCreateDate));
    pager.setCurrentItem(pagerPosition);
    OnPageChangeListener mPageChangeListener = new OnPageChangeListener() {
        @Override
        public void onPageScrollStateChanged(int arg0) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onPageSelected(int pos) {
            CheckImageAuthorAndRefreshOptionsMenu(pos);
        }

    };
    pager.setOnPageChangeListener(mPageChangeListener);
    CheckImageAuthorAndRefreshOptionsMenu(pagerPosition); // ? create  ? ?.
}

From source file:cn.laojing.smarthome.VoiceActivity.java

@Override
public void onResults(Bundle results) {
    long end2finish = System.currentTimeMillis() - speechEndTime;
    ArrayList<String> nbest = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    print("?" + Arrays.toString(nbest.toArray(new String[nbest.size()])));
    mListViewAdapter.setCmds(nbest.get(0));
    mVoiceControl.runCommand(nbest.get(0));
}