List of usage examples for android.os Bundle getStringArrayList
@Override
@Nullable
public ArrayList<String> getStringArrayList(@Nullable String key)
From source file:nz.ac.otago.psyanlab.common.designer.subject.OptionsFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Bundle args = getArguments(); int kind = args.getInt(ARG_KIND); mQuestion = Question.getNewInstance(kind); mQuestion.name = args.getString(ARG_NAME); mQuestion.text = args.getString(ARG_TEXT); mQuestion.hint = args.getString(ARG_HINT); mQuestion.required = args.getBoolean(ARG_REQUIRED); mQuestion.options = args.getStringArrayList(ARG_OPTIONS); mViews = new ViewHolder(view); mViews.setOnQuestionTypeChangeListener(mListener); mViews.initViews(getActivity());/*from w w w . j a v a 2s . c o m*/ mViews.setViewValues(mQuestion); }
From source file:com.chexiaoya.gaodemapdemo.SpeechSearchActivity.java
@Override public void onResults(Bundle results) { if (results != null) { long end2finish = System.currentTimeMillis() - speechEndTime; status = STATUS_None;// w w w . j a va2 s. c om ArrayList<String> nbest = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); 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)"; } Log.i(TAG, "onResults-----> " + nbest.get(0) + strEnd2Finish); String result = nbest.get(0) + strEnd2Finish; mResultText.setText(result); } }
From source file:org.botlibre.sdk.activity.MicConfiguration.java
@Override public void onResults(Bundle results) { List<String> text = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); editTextSpeech.setText(text.get(0)); }
From source file:hackathon.openrice.CardsActivity.java
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); Bundle extras = getIntent().getExtras(); String keyword = null;/*from ww w.ja va 2s .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.facebook.internal.BundleJSONConverterTests.java
@SmallTest public void testSimpleValues() throws JSONException { ArrayList<String> arrayList = new ArrayList<String>(); arrayList.add("1st"); arrayList.add("2nd"); arrayList.add("third"); Bundle innerBundle1 = new Bundle(); innerBundle1.putInt("inner", 1); Bundle innerBundle2 = new Bundle(); innerBundle2.putString("inner", "2"); innerBundle2.putStringArray("deep list", new String[] { "7", "8" }); innerBundle1.putBundle("nested bundle", innerBundle2); Bundle b = new Bundle(); b.putBoolean("boolValue", true); b.putInt("intValue", 7); b.putLong("longValue", 5000000000l); b.putDouble("doubleValue", 3.14); b.putString("stringValue", "hello world"); b.putStringArray("stringArrayValue", new String[] { "first", "second" }); b.putStringArrayList("stringArrayListValue", arrayList); b.putBundle("nested", innerBundle1); JSONObject json = BundleJSONConverter.convertToJSON(b); assertNotNull(json);// w w w .ja v a2 s .c o m assertEquals(true, json.getBoolean("boolValue")); assertEquals(7, json.getInt("intValue")); assertEquals(5000000000l, json.getLong("longValue")); assertEquals(3.14, json.getDouble("doubleValue")); assertEquals("hello world", json.getString("stringValue")); JSONArray jsonArray = json.getJSONArray("stringArrayValue"); assertEquals(2, jsonArray.length()); assertEquals("first", jsonArray.getString(0)); assertEquals("second", jsonArray.getString(1)); jsonArray = json.getJSONArray("stringArrayListValue"); assertEquals(3, jsonArray.length()); assertEquals("1st", jsonArray.getString(0)); assertEquals("2nd", jsonArray.getString(1)); assertEquals("third", jsonArray.getString(2)); JSONObject innerJson = json.getJSONObject("nested"); assertEquals(1, innerJson.getInt("inner")); innerJson = innerJson.getJSONObject("nested bundle"); assertEquals("2", innerJson.getString("inner")); jsonArray = innerJson.getJSONArray("deep list"); assertEquals(2, jsonArray.length()); assertEquals("7", jsonArray.getString(0)); assertEquals("8", jsonArray.getString(1)); Bundle finalBundle = BundleJSONConverter.convertToBundle(json); assertNotNull(finalBundle); assertEquals(true, finalBundle.getBoolean("boolValue")); assertEquals(7, finalBundle.getInt("intValue")); assertEquals(5000000000l, finalBundle.getLong("longValue")); assertEquals(3.14, finalBundle.getDouble("doubleValue")); assertEquals("hello world", finalBundle.getString("stringValue")); List<String> stringList = finalBundle.getStringArrayList("stringArrayValue"); assertEquals(2, stringList.size()); assertEquals("first", stringList.get(0)); assertEquals("second", stringList.get(1)); stringList = finalBundle.getStringArrayList("stringArrayListValue"); assertEquals(3, stringList.size()); assertEquals("1st", stringList.get(0)); assertEquals("2nd", stringList.get(1)); assertEquals("third", stringList.get(2)); Bundle finalInnerBundle = finalBundle.getBundle("nested"); assertEquals(1, finalInnerBundle.getInt("inner")); finalBundle = finalInnerBundle.getBundle("nested bundle"); assertEquals("2", finalBundle.getString("inner")); stringList = finalBundle.getStringArrayList("deep list"); assertEquals(2, stringList.size()); assertEquals("7", stringList.get(0)); assertEquals("8", stringList.get(1)); }
From source file:com.glabs.homegenie.util.VoiceControl.java
@Override public void onResults(Bundle results) { if ((results != null) && results.containsKey(SpeechRecognizer.RESULTS_RECOGNITION)) { List<String> heard = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); float[] scores = results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES); String msg = ""; for (String s : heard) { Toast.makeText(_hgcontext.getApplicationContext(), "Executing: " + s, 20000).show(); interpretInput(s);// w ww . j a v a 2s. com // msg += s; break; } } }
From source file:com.vyasware.vaani.MainActivity.java
@Override public void onResults(Bundle results) { Log.i(LOG_TAG, "onResults"); ArrayList<String> matches = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); input = matches.get(0);// w w w . ja v a 2 s. c o m /* for (String result : matches) text += result + "\n";*/ returnedText.setText(input); new Thread(new Runnable() { @Override public void run() { performAction(input); } }).start(); }
From source file:com.anjlab.android.iab.v3.BillingProcessor.java
private boolean loadPurchasesByType(String type, BillingCache cacheStorage) { if (!isInitialized()) return false; try {/*from www. j a va2 s.c o m*/ Bundle bundle = billingService.getPurchases(Constants.GOOGLE_API_VERSION, contextPackageName, type, null); if (bundle.getInt(Constants.RESPONSE_CODE) == Constants.BILLING_RESPONSE_RESULT_OK) { cacheStorage.clear(); ArrayList<String> purchaseList = bundle.getStringArrayList(Constants.INAPP_PURCHASE_DATA_LIST); ArrayList<String> signatureList = bundle.getStringArrayList(Constants.INAPP_DATA_SIGNATURE_LIST); for (int i = 0; i < purchaseList.size(); i++) { String jsonData = purchaseList.get(i); JSONObject purchase = new JSONObject(jsonData); String signature = signatureList != null && signatureList.size() > i ? signatureList.get(i) : null; cacheStorage.put(purchase.getString(Constants.RESPONSE_PRODUCT_ID), jsonData, signature); } } return true; } catch (Exception e) { if (eventHandler != null) eventHandler.onBillingError(Constants.BILLING_ERROR_FAILED_LOAD_PURCHASES, e); Log.e(LOG_TAG, e.toString()); } return false; }
From source file:com.thunder.iap.IAPActivity.java
/** * * @param skuList the list of available skus * @param listener/*from w ww.jav a 2 s . c om*/ */ public void getSkuDetails(final ArrayList<String> skuList, final SkuDetailsListener listener) { new Thread(new Runnable() { @Override public void run() { Bundle querySkus = new Bundle(); querySkus.putStringArrayList("ITEM_ID_LIST", skuList); try { Bundle skuDetails = mService.getSkuDetails(3, getPackageName(), "inapp", querySkus); ArrayList<JSONObject> result = new ArrayList<JSONObject>(); int response = skuDetails.getInt("RESPONSE_CODE"); if (response == 0) { ArrayList<String> responseList = skuDetails.getStringArrayList("DETAILS_LIST"); for (String thisResponse : responseList) { JSONObject object = null; try { object = new JSONObject(thisResponse); } catch (JSONException e) { e.printStackTrace(); } //String sku = object.getString("productId"); //String price = object.getString("price"); //if (sku.equals("premiumUpgrade")) mPremiumUpgradePrice = price; //else if (sku.equals("gas")) mGasPrice = price; result.add(object); } listener.onResult(result); } else { listener.onServerError(skuDetails); } } catch (RemoteException e) { e.printStackTrace(); listener.onError(e); } } }).start(); }
From source file:eu.faircode.adblocker.IAB.java
public boolean isAvailable(String sku) throws RemoteException, JSONException { // Get available SKUs ArrayList<String> skuList = new ArrayList<>(); skuList.add(sku);/*from w w w. ja v a 2s . co m*/ Bundle query = new Bundle(); query.putStringArrayList("ITEM_ID_LIST", skuList); Bundle bundle = service.getSkuDetails(IAB_VERSION, context.getPackageName(), "inapp", query); Log.i(TAG, "getSkuDetails"); Util.logBundle(bundle); int response = (bundle == null ? -1 : bundle.getInt("RESPONSE_CODE", -1)); Log.i(TAG, "Response=" + getResult(response)); if (response != 0) throw new IllegalArgumentException(getResult(response)); // Check available SKUs boolean found = false; ArrayList<String> details = bundle.getStringArrayList("DETAILS_LIST"); if (details != null) for (String item : details) { JSONObject object = new JSONObject(item); if (sku.equals(object.getString("productId"))) { found = true; break; } } Log.i(TAG, sku + "=" + found); return found; }