List of usage examples for android.os Bundle getStringArrayList
@Override
@Nullable
public ArrayList<String> getStringArrayList(@Nullable String key)
From source file:com.example.haizhu.myvoiceassistant.ui.RobotChatActivity.java
public void initListener() { recognitionListener = new RecognitionListener() { @Override// www. j a v a 2 s . c o m public void onReadyForSpeech(Bundle bundle) { } @Override public void onBeginningOfSpeech() { } @Override public void onRmsChanged(float v) { final int VTAG = 0xFF00AA01; Integer rawHeight = (Integer) speechWave.getTag(VTAG); if (rawHeight == null) { rawHeight = speechWave.getLayoutParams().height; speechWave.setTag(VTAG, rawHeight); } RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) speechWave.getLayoutParams(); params.height = (int) (rawHeight * v * 0.01); params.height = Math.max(params.height, speechWave.getMeasuredWidth()); speechWave.setLayoutParams(params); } @Override public void onBufferReceived(byte[] bytes) { } @Override public void onEndOfSpeech() { } @Override public void onError(int error) { StringBuilder sb = new StringBuilder(); switch (error) { case SpeechRecognizer.ERROR_AUDIO: sb.append(""); break; case SpeechRecognizer.ERROR_SPEECH_TIMEOUT: sb.append(""); break; case SpeechRecognizer.ERROR_CLIENT: sb.append(""); break; case SpeechRecognizer.ERROR_INSUFFICIENT_PERMISSIONS: sb.append("???"); break; case SpeechRecognizer.ERROR_NETWORK: sb.append(""); break; case SpeechRecognizer.ERROR_NO_MATCH: sb.append("?"); break; case SpeechRecognizer.ERROR_RECOGNIZER_BUSY: sb.append(""); break; case SpeechRecognizer.ERROR_SERVER: sb.append("?"); break; case SpeechRecognizer.ERROR_NETWORK_TIMEOUT: sb.append(""); break; } sb.append(":" + error); print("" + sb.toString()); Message message = mhandler.obtainMessage(RECOGNIZE_ERROR); message.obj = sb.toString(); mhandler.sendMessage(message); } @Override public void onResults(Bundle results) { ArrayList<String> nbest = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); print("?" + Arrays.toString(nbest.toArray(new String[nbest.size()]))); String json_res = results.getString("origin_result"); String results_nlu_json = results.getString("results_nlu"); Message message = mhandler.obtainMessage(RECOGNIZE_SUCESS); message.obj = results_nlu_json; mhandler.sendMessage(message); //?UI ResultsAnalysisManager.analyseResult(results_nlu_json); print("result_nlu=\n" + results_nlu_json); try { print("origin_result=\n" + new JSONObject(json_res).toString(4)); } catch (Exception e) { print("origin_result=[warning: bad json]\n" + json_res); } } @Override public void onPartialResults(Bundle bundle) { } @Override public void onEvent(int eventType, Bundle bundle) { switch (eventType) { case 11: String reason = bundle.get("reason") + ""; print("EVENT_ERROR, " + reason); Message message = mhandler.obtainMessage(RECOGNIZE_ERROR); message.obj = reason; mhandler.sendMessage(message); break; } } }; speechSynthesizerListener = new SpeechSynthesizerListener() { @Override public void onStartWorking(SpeechSynthesizer speechSynthesizer) { } @Override public void onSpeechStart(SpeechSynthesizer speechSynthesizer) { } @Override public void onNewDataArrive(SpeechSynthesizer speechSynthesizer, byte[] bytes, boolean b) { } @Override public void onBufferProgressChanged(SpeechSynthesizer speechSynthesizer, int i) { } @Override public void onSpeechProgressChanged(SpeechSynthesizer speechSynthesizer, int i) { } @Override public void onSpeechPause(SpeechSynthesizer speechSynthesizer) { } @Override public void onSpeechResume(SpeechSynthesizer speechSynthesizer) { } @Override public void onCancel(SpeechSynthesizer speechSynthesizer) { } @Override public void onSynthesizeFinish(SpeechSynthesizer speechSynthesizer) { } @Override public void onSpeechFinish(SpeechSynthesizer speechSynthesizer) { } @Override public void onError(SpeechSynthesizer speechSynthesizer, SpeechError speechError) { } }; }
From source file:atlc.granadaaccessibilityranking.VoiceActivity.java
/******************************************************************************************************** * This class implements the {@link android.speech.RecognitionListener} interface, * thus it implement its methods. However not all of them were interesting to us: * ****************************************************************************************************** *//*from w ww .j a v a 2s . com*/ @SuppressLint("InlinedApi") /* * (non-Javadoc) * * Invoked when the ASR provides recognition results * * @see android.speech.RecognitionListener#onResults(android.os.Bundle) */ @Override public void onResults(Bundle results) { if (results != null) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { //Checks the API level because the confidence scores are supported only from API level 14: //http://developer.android.com/reference/android/speech/SpeechRecognizer.html#CONFIDENCE_SCORES //Processes the recognition results and their confidences processAsrResults(results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION), results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES)); // Attention: It is not RecognizerIntent.EXTRA_RESULTS, that is for intents (see the ASRWithIntent app) } else { //Processes the recognition results and their confidences processAsrResults(results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION), null); } } else //Processes recognition errors processAsrError(SpeechRecognizer.ERROR_NO_MATCH); }
From source file:org.linphone.purchase.InAppPurchaseHelper.java
public void getPurchasedItemsAsync() { new Thread(new Runnable() { public void run() { final ArrayList<Purchasable> items = new ArrayList<Purchasable>(); String continuationToken = null; do {/*w w w. j a va 2 s . c om*/ Bundle purchasedItems = null; try { purchasedItems = mService.getPurchases(API_VERSION, mContext.getPackageName(), ITEM_TYPE_SUBS, continuationToken); } catch (RemoteException e) { Log.e(e); } if (purchasedItems != null) { int response = purchasedItems.getInt(RESPONSE_CODE); if (response == RESPONSE_RESULT_OK) { ArrayList<String> purchaseDataList = purchasedItems .getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = purchasedItems .getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST); continuationToken = purchasedItems.getString(RESPONSE_INAPP_CONTINUATION_TOKEN); for (int i = 0; i < purchaseDataList.size(); ++i) { String purchaseData = purchaseDataList.get(i); String signature = signatureList.get(i); Log.d("[In-app purchase] " + purchaseData); Purchasable item = verifySignature(purchaseData, signature); if (item != null) { items.add(item); } } } else { Log.e("[In-app purchase] Error: responde code is not ok: " + responseCodeToErrorMessage(response)); mListener.onError(responseCodeToErrorMessage(response)); } } } while (continuationToken != null); if (mHandler != null && mListener != null) { mHandler.post(new Runnable() { public void run() { mListener.onPurchasedItemsQueryFinished(items); } }); } } }).start(); }
From source file:com.pileproject.drive.programming.visual.activity.ProgrammingActivity.java
@Override public void onDialogEventHandled(int requestCode, DialogInterface dialog, int which, Bundle params) { switch (requestCode) { case DIALOG_REQUEST_CODE_DID_NOT_SELECT_DEVICE: { startActivity(SettingActivity.createIntent(getApplicationContext())); break;// w w w . j a v a 2 s . co m } case DIALOG_REQUEST_CODE_DELETE_ALL_BLOCK: { if (which == DialogInterface.BUTTON_NEGATIVE) { break; } mSpaceManager.deleteAllBlocks(); break; } case DIALOG_REQUEST_CODE_PROGRAM_LIST: { if (which == DialogInterface.BUTTON_NEGATIVE) { break; } boolean isSample = params.getBoolean(KEY_IS_SAMPLE); ArrayList<String> programs = params.getStringArrayList(KEY_SAMPLE_PROGRAMS); String programName = programs.get(which); mSpaceManager.deleteAllBlocks(); // delete existing blocks if (isSample) { mSpaceManager.loadSampleProgram(programName); } else { mSpaceManager.loadUserProgram(programName); } break; } } }
From source file:com.open.file.manager.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); actcontext = getApplicationContext(); operator = new FileOperations(this); setContentView(R.layout.fragment_pager_layout); mPager = (ViewPager) findViewById(R.id.pager); mAdapter = new FragmentAdapter(getSupportFragmentManager(), this); if (savedInstanceState != null) { ArrayList<String> oldfrags = savedInstanceState.getStringArrayList("fragments"); for (String curfrag : oldfrags) { mAdapter.addFragment(GridFragment.newInstance(curfrag)); }/*from www . j av a 2s. com*/ ArrayList<String> oldselected = savedInstanceState.getStringArrayList("selectedfiles"); for (String curselected : oldselected) { selectedfiles.add(new File(curselected)); } } mPager.setAdapter(mAdapter); if (mAdapter.selectpathmissing()) { mAdapter.addFragment(SelectPathFragment.newInstance()); } if (selectedfiles.size() > 0) { mMode = startActionMode(getCutCopyCallback()); } curfrag = mAdapter.getcurrentfrag(); mPager.setCurrentItem(curfrag); acthandler = new ActivityHandler(); if (!restoreOperations(savedInstanceState) && operator.isMyServiceRunning()) { Log.d("servicerunning?", Boolean.toString(operator.isMyServiceRunning())); Log.d("restart", "activity"); Message restartmsg = Message.obtain(); restartmsg.what = Consts.MSG_ACTIVITYRESTART; CutCopyService.mHandler.sendMessage(restartmsg); } }
From source file:ivl.android.moneybalance.CalculationEditorActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); supportRequestWindowFeature(WindowCompat.FEATURE_ACTION_BAR); setContentView(R.layout.calculation_editor); setTitle(R.string.new_calculation); titleField = (EditText) findViewById(R.id.calculation_title); currencyField = (Spinner) findViewById(R.id.calculation_currency); personList = (LinearLayout) findViewById(R.id.person_list); CurrencySpinnerAdapter adapter = new CurrencySpinnerAdapter(this); int selected = adapter.findItem(getDefaultCurrency()); currencyField.setAdapter(adapter);//from w w w .j a v a 2 s.com currencyField.setSelection(selected); if (savedInstanceState != null) { List<String> personNames = savedInstanceState.getStringArrayList("personNames"); if (personNames != null) { for (String personName : personNames) { PersonView view = addPersonRow(); view.nameField.setText(personName); } } } createOrDeletePersonRows(); }
From source file:com.jbirdvegas.mgerrit.CardsFragment.java
@Override public Loader<Cursor> onCreateLoader(int id, @Nullable Bundle args) { if (args == null) { SearchQueryChanged ev = mEventBus.getStickyEvent(SearchQueryChanged.class); if (ev != null) { String to = ev.getClazzName(); if (mParent.getClass().getSimpleName().equals(to)) args = ev.getBundle();//from ww w . j a v a 2 s . co m } } if (args != null) { String databaseQuery = args.getString(SearchQueryChanged.KEY_WHERE); if (databaseQuery != null && !databaseQuery.isEmpty()) { if (args.getStringArrayList(SearchQueryChanged.KEY_BINDARGS) != null) { /* Create a copy as the findCommits function can modify the contents of bindArgs * and we want each receiver to use the bindArgs from the original broadcast */ ArrayList<String> bindArgs = new ArrayList<>(); bindArgs.addAll(args.getStringArrayList(SearchQueryChanged.KEY_BINDARGS)); return UserChanges.findCommits(mParent, getQuery(), databaseQuery, bindArgs); } } } return UserChanges.findCommits(mParent, getQuery(), null, null); }
From source file:com.onebus.view.MainActivity.java
public void onResults(Bundle results) { long end2finish = System.currentTimeMillis() - speechEndTime; status = STATUS_None;// w ww . ja v a2s . c o m ArrayList<String> nbest = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); /* * print("?" + Arrays.toString(nbest.toArray(new * String[nbest.size()]))); */ Intent intent = new Intent(); intent.setClass(getApplicationContext(), SearchActivity.class); intent.putExtra("tag", 1); intent.putExtra("strMessage", nbest.get(0).toString()); startActivity(intent); String json_res = results.getString("origin_result"); String strEnd2Finish = ""; if (end2finish < 60 * 1000) { strEnd2Finish = "(waited " + end2finish + "ms)"; } cancel(); }
From source file:li.barter.fragments.AddOrEditBookFragment.java
/** * @param args The Fragment arguments// w w w . ja v a 2s.c o m */ private void loadDetailsForIntent(final Bundle args) { mIsbnNumber = args.getString(Keys.ISBN); final String title = args.getString(Keys.BOOK_TITLE); final String author = args.getString(Keys.AUTHOR); final String description = args.getString(Keys.DESCRIPTION); final List<String> barterTypes = args.getStringArrayList(Keys.BARTER_TYPES); mIsbnEditText.setText(mIsbnNumber); mTitleEditText.setTextWithFilter(title, false); mAuthorEditText.setText(author); mDescriptionEditText.setText(description); setCheckBoxesForBarterTypes(barterTypes); }
From source file:com.nokia.example.paymentoneapk.PaymentOneAPKActivity.java
private void getPurchases() { Log.d(TAG, "PaymentOneAPKActivity.getPurchases"); new Thread(new Runnable() { @Override/*from w ww . j ava 2 s . co m*/ public void run() { Bundle ownedItems = null; try { ownedItems = mService.getPurchases(API_VERSION, getPackageName(), "inapp", null); } catch (final RemoteException e) { Log.e(TAG, "got an exception", e); return; } final int response = ownedItems.getInt("RESPONSE_CODE"); Log.d(TAG, "getPurchases response code = " + response); if (response != PaymentOneAPKUtils.RESULT_OK) { Log.e(TAG, String.format("response code = %d : %s", response, getErrorMessage(response))); return; } final ArrayList<String> ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST"); for (final String ownedSku : ownedSkus) { Log.d(TAG, "ownedSku = " + ownedSku); } } }).start(); }