List of usage examples for android.os Bundle getStringArrayList
@Override
@Nullable
public ArrayList<String> getStringArrayList(@Nullable String key)
From source file:org.linphone.purchase.InAppPurchaseHelper.java
private ArrayList<Purchasable> getAvailableItemsForPurchase() { ArrayList<Purchasable> products = new ArrayList<Purchasable>(); ArrayList<String> skuList = LinphonePreferences.instance().getInAppPurchasables(); Bundle querySkus = new Bundle(); querySkus.putStringArrayList(SKU_DETAILS_ITEM_LIST, skuList); Bundle skuDetails = null; try {//from ww w . jav a 2 s. c o m skuDetails = mService.getSkuDetails(API_VERSION, mContext.getPackageName(), ITEM_TYPE_SUBS, querySkus); } catch (RemoteException e) { Log.e(e); } if (skuDetails != null) { int response = skuDetails.getInt(RESPONSE_CODE); if (response == RESPONSE_RESULT_OK) { ArrayList<String> responseList = skuDetails.getStringArrayList(SKU_DETAILS_LIST); for (String thisResponse : responseList) { try { JSONObject object = new JSONObject(thisResponse); String id = object.getString(SKU_DETAILS_PRODUCT_ID); String price = object.getString(SKU_DETAILS_PRICE); String title = object.getString(SKU_DETAILS_TITLE); String desc = object.getString(SKU_DETAILS_DESC); Purchasable purchasable = new Purchasable(id).setTitle(title).setDescription(desc) .setPrice(price); Log.w("Purchasable item " + purchasable.getDescription()); products.add(purchasable); } catch (JSONException e) { Log.e(e); } } } else { Log.e("[In-app purchase] Error: responde code is not ok: " + responseCodeToErrorMessage(response)); mListener.onError(responseCodeToErrorMessage(response)); } } return products; }
From source file:conversandroid.RichASR.java
/******************************************************************************************************** * Process ASR events/*from w w w . jav a2 s.c om*/ * ****************************************************************************************************** */ /* * (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) { Log.i(LOGTAG, "ASR results received ok"); ((TextView) findViewById(R.id.feedbackTxt)).setText("Results ready :D"); //Retrieves the N-best list and the confidences from the ASR result ArrayList<String> nBestList = results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); float[] nBestConfidences = null; if (Build.VERSION.SDK_INT >= 14) //Checks the API level because the confidence scores are supported only from API level 14 nBestConfidences = results.getFloatArray(SpeechRecognizer.CONFIDENCE_SCORES); //Creates a collection of strings, each one with a recognition result and its confidence //following the structure "Phrase matched (conf: 0.5)" ArrayList<String> nBestView = new ArrayList<String>(); for (int i = 0; i < nBestList.size(); i++) { if (nBestConfidences != null) { if (nBestConfidences[i] >= 0) nBestView.add( nBestList.get(i) + " (conf: " + String.format("%.2f", nBestConfidences[i]) + ")"); else nBestView.add(nBestList.get(i) + " (no confidence value available)"); } else nBestView.add(nBestList.get(i) + " (no confidence value available)"); } //Includes the collection in the ListView of the GUI setListView(nBestView); } else { Log.e(LOGTAG, "ASR results null"); //There was a recognition error ((TextView) findViewById(R.id.feedbackTxt)).setText("Error"); } stopListening(); }
From source file:org.strongswan.android.ui.SelectedApplicationsListFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); setHasOptionsMenu(true);/*from w w w . j a v a2 s . com*/ getListView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); mAdapter = new SelectedApplicationsAdapter(getActivity()); setListAdapter(mAdapter); setListShown(false); ArrayList<String> selection; if (savedInstanceState == null) { selection = getActivity().getIntent() .getStringArrayListExtra(VpnProfileDataSource.KEY_SELECTED_APPS_LIST); } else { selection = savedInstanceState.getStringArrayList(VpnProfileDataSource.KEY_SELECTED_APPS_LIST); } mSelection = new TreeSet<>(selection); getLoaderManager().initLoader(0, null, this); }
From source file:org.onepf.oms.appstore.SamsungAppsBillingService.java
private boolean processItemsBundle(Bundle itemsBundle, String itemGroupId, Inventory inventory, boolean querySkuDetails, boolean addPurchase, boolean addConsumable, Set<String> queryItemIds) { if (itemsBundle == null || itemsBundle.getInt(KEY_NAME_STATUS_CODE) != IAP_ERROR_NONE) { return false; }/*w w w. j a v a2s.co m*/ ArrayList<String> items = itemsBundle.getStringArrayList(KEY_NAME_RESULT_LIST); for (String itemString : items) { try { JSONObject item = new JSONObject(itemString); String itemId = item.getString(JSON_KEY_ITEM_ID); if (queryItemIds == null || queryItemIds.contains(itemId)) { String rawType = item.getString(JSON_KEY_TYPE); // Do not add consumable item into inventory if (rawType.equals(ITEM_TYPE_CONSUMABLE) && !addConsumable) { continue; } String itemType = rawType.equals(ITEM_TYPE_SUBSCRIPTION) ? IabHelper.ITEM_TYPE_SUBS : IabHelper.ITEM_TYPE_INAPP; String sku = OpenIabHelper.getSku(OpenIabHelper.NAME_SAMSUNG, itemGroupId + '/' + itemId); if (addPurchase) { Purchase purchase = new Purchase(OpenIabHelper.NAME_SAMSUNG); purchase.setItemType(itemType); purchase.setSku(sku); purchase.setPackageName(activity.getPackageName()); purchase.setPurchaseState(0); purchase.setDeveloperPayload(""); purchase.setOrderId(item.getString(JSON_KEY_PAYMENT_ID)); purchase.setPurchaseTime(Long.parseLong(item.getString(JSON_KEY_PURCHASE_DATE))); purchase.setToken(item.getString(JSON_KEY_PURCHASE_ID)); inventory.addPurchase(purchase); } if (!addPurchase || querySkuDetails) { String name = item.getString(JSON_KEY_ITEM_NAME); String price = item.getString(JSON_KEY_ITEM_PRICE_STRING); String desc = item.getString(JSON_KEY_ITEM_DESC); inventory.addSkuDetails(new SkuDetails(itemType, sku, name, price, desc)); } } } catch (JSONException e) { Log.e(TAG, "JSON parse error: " + e.getMessage()); } } return items.size() == ITEM_RESPONSE_COUNT; }
From source file:net.zionsoft.obadiah.model.InAppBillingHelper.java
public void loadAdsRemovalState(final OnAdsRemovalStateLoadedListener onLoaded) { if (mStatus != Status.INITIALIZED) return;//from ww w . ja v a2 s . com new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... params) { try { final Bundle purchases = mInAppBillingService.getPurchases(BILLING_VERSION, mContext.getPackageName(), ITEM_TYPE_INAPP, null); final int response = purchases.getInt("RESPONSE_CODE"); if (response != BILLING_RESPONSE_RESULT_OK) { Analytics.trackException("Failed to load purchases - " + response); return false; } final String adsProductId = mContext.getString(R.string.in_app_product_no_ads); for (String data : purchases.getStringArrayList("INAPP_PURCHASE_DATA_LIST")) { final JSONObject purchaseObject = new JSONObject(data); if (purchaseObject.getString("productId").equals(adsProductId) && purchaseObject.getInt("purchaseState") == 0) { return true; } } return false; } catch (Exception e) { Crashlytics.logException(e); return false; } } @Override protected void onPostExecute(Boolean result) { if (mStatus != InAppBillingHelper.Status.INITIALIZED) return; onLoaded.onAdsRemovalStateLoaded(result); } }.execute(); }
From source file:com.jbirdvegas.mgerrit.PatchSetViewerActivity.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 (GerritControllerActivity.class.getSimpleName().equals(to)) args = ev.getBundle();//w w w .ja v a 2s . c o 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(this, mStatus, databaseQuery, bindArgs); } } } return UserChanges.findCommits(this, mStatus, null, null); }
From source file:com.mercandalli.android.apps.files.file.audio.FileAudioActivity.java
@Override public void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Initialize View, player and ChromeCast. setContentView(R.layout.activity_file_audio); mFileAudioPlayer = FileAudioPlayer.getInstance(this); mFileAudioPlayer.registerOnPlayerStatusChangeListener(this); mFileAudioCast.onCreate(this); if (savedInstanceState == null) { mFirstStart = true;/*www .j av a 2 s .c o m*/ } final Toolbar toolbar = (Toolbar) findViewById(R.id.activity_file_audio_toolbar); if (toolbar != null) { setSupportActionBar(toolbar); toolbar.setBackgroundColor(ContextCompat.getColor(this, R.color.actionbar_audio)); final ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle("FileSpace - Audio"); } } final Window window = getWindow(); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.setStatusBarColor(ContextCompat.getColor(this, R.color.notifications_bar_audio)); } mTitleTextView = (TextView) findViewById(R.id.title); mSizeTextView = (TextView) findViewById(R.id.size); mSliderNumber = (Slider) findViewById(R.id.sliderNumber); mSliderNumber.setValueToDisplay(new Slider.ValueToDisplay() { @Override public String convert(int value) { return getTimeStr(value); } }); mSliderNumber.setOnValueChangedListener(new Slider.OnValueChangedListener() { @Override public void onValueChanged(int value) { } @Override public void onValueChangedUp(int value) { mFileAudioPlayer.seekTo(value); } }); mPlayPauseView = (PlayPauseView) findViewById(R.id.activity_file_audio_play); mPlayPauseView.setOnClickListener(this); findViewById(R.id.activity_file_audio_next).setOnClickListener(this); findViewById(R.id.activity_file_audio_previous).setOnClickListener(this); final Bundle bundle = getIntent().getExtras(); if (bundle != null && bundle.containsKey(EXTRA_IS_ONLINE) && bundle.containsKey(EXTRA_FILE_CURRENT_POSITION) && bundle.containsKey(EXTRA_FILES_PATH)) { // Get data mIsOnline = bundle.getBoolean(EXTRA_IS_ONLINE); mCurrentPosition = bundle.getInt(EXTRA_FILE_CURRENT_POSITION); final List<String> absolutePathArray = bundle.getStringArrayList(EXTRA_FILES_PATH); if (absolutePathArray != null) { for (String absolutePath : absolutePathArray) { if (mIsOnline) { mFileAudioModelList.add( ((FileAudioModel.FileAudioModelBuilder) (new FileAudioModel.FileAudioModelBuilder() .isOnline(true).url(absolutePath))).build()); } else { mFileAudioModelList.add( new FileAudioModel.FileAudioModelBuilder().file(new File(absolutePath)).build()); } } } if (mFileAudioModelList.isEmpty()) { Toast.makeText(this, "Oops, I have an empty list :(", Toast.LENGTH_SHORT).show(); finish(); return; } if (mFirstStart) { mFileAudioPlayer.startMusic(mCurrentPosition, mFileAudioModelList); mFileAudioCast.startMusic(mCurrentPosition, mFileAudioModelList); } else { syncSongs(mFileAudioPlayer.getCurrentMusicIndex(), mFileAudioPlayer.getFileAudioModelList()); } } mFirstStart = false; }
From source file:com.envyserve.githubreference.billing.BillingProcessor.java
private List<SkuDetails> getSkuDetails(ArrayList<String> productIdList, String purchaseType) { if (billingService != null && productIdList != null && productIdList.size() > 0) { try {/*from w w w . j a v a 2 s . co m*/ Bundle products = new Bundle(); products.putStringArrayList(Constants.PRODUCTS_LIST, productIdList); Bundle skuDetails = billingService.getSkuDetails(Constants.GOOGLE_API_VERSION, contextPackageName, purchaseType, products); int response = skuDetails.getInt(Constants.RESPONSE_CODE); if (response == Constants.BILLING_RESPONSE_RESULT_OK) { ArrayList<SkuDetails> productDetails = new ArrayList<SkuDetails>(); for (String responseLine : skuDetails.getStringArrayList(Constants.DETAILS_LIST)) { JSONObject object = new JSONObject(responseLine); SkuDetails product = new SkuDetails(object); productDetails.add(product); } return productDetails; } else { if (eventHandler != null) eventHandler.onBillingError(response, null); Log.e(LOG_TAG, String.format("Failed to retrieve info for %d products, %d", productIdList.size(), response)); } } catch (Exception e) { Log.e(LOG_TAG, String.format("Failed to call getSkuDetails %s", e.toString())); } } return null; }
From source file:net.named_data.nfd.PingClientFragment.java
@Override public void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if (m_pingResultListAdapter == null) { m_pingResultListAdapter = new PingResultListAdapter(getActivity()); }/*w ww . j av a2 s .c o m*/ m_pingResultListView.setAdapter(m_pingResultListAdapter); if (savedInstanceState != null) { setButtonState(savedInstanceState.getBoolean(TAG_PING_STATUS)); m_pingNameEditText.setText(savedInstanceState.getString(TAG_PING_NAME)); m_pingResultListAdapter.setData(savedInstanceState.getStringArrayList(TAG_PING_DATA)); Serializable state = savedInstanceState.getSerializable(TAG_PING_STATE); if (!m_isStartState && state != null) { m_client = new PingClient(m_pingNameEditText.getText().toString(), state); } } }
From source file:jp.sonymusicstudio.cast.castcompanionlibrary.utils.Utils.java
/** * Builds and returns a {@link MediaInfo} that was wrapped in a {@link Bundle} by * <code>mediaInfoToBundle</code>. It is assumed that the type of the {@link MediaInfo} is * {@code MediaMetaData.MEDIA_TYPE_MOVIE} * * @see <code>mediaInfoToBundle()</code> *///from w w w . j a va2 s . co m public static MediaInfo bundleToMediaInfo(Bundle wrapper) { if (wrapper == null) { return null; } MediaMetadata metaData = new MediaMetadata(wrapper.getInt(KEY_MEDIA_TYPE)); metaData.putString(MediaMetadata.KEY_SUBTITLE, wrapper.getString(MediaMetadata.KEY_SUBTITLE)); metaData.putString(MediaMetadata.KEY_TITLE, wrapper.getString(MediaMetadata.KEY_TITLE)); metaData.putString(MediaMetadata.KEY_STUDIO, wrapper.getString(MediaMetadata.KEY_STUDIO)); metaData.putString(MediaMetadata.KEY_ALBUM_ARTIST, wrapper.getString(MediaMetadata.KEY_ALBUM_ARTIST)); metaData.putString(MediaMetadata.KEY_ALBUM_TITLE, wrapper.getString(MediaMetadata.KEY_ALBUM_TITLE)); metaData.putString(MediaMetadata.KEY_COMPOSER, wrapper.getString(MediaMetadata.KEY_COMPOSER)); metaData.putString(MediaMetadata.KEY_SERIES_TITLE, wrapper.getString(MediaMetadata.KEY_SERIES_TITLE)); metaData.putInt(MediaMetadata.KEY_SEASON_NUMBER, wrapper.getInt(MediaMetadata.KEY_SEASON_NUMBER)); metaData.putInt(MediaMetadata.KEY_EPISODE_NUMBER, wrapper.getInt(MediaMetadata.KEY_EPISODE_NUMBER)); long releaseDateMillis = wrapper.getLong(MediaMetadata.KEY_RELEASE_DATE, 0); if (releaseDateMillis > 0) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(releaseDateMillis); metaData.putDate(MediaMetadata.KEY_RELEASE_DATE, calendar); } ArrayList<String> images = wrapper.getStringArrayList(KEY_IMAGES); if (images != null && !images.isEmpty()) { for (String url : images) { Uri uri = Uri.parse(url); metaData.addImage(new WebImage(uri)); } } String customDataStr = wrapper.getString(KEY_CUSTOM_DATA); JSONObject customData = null; if (!TextUtils.isEmpty(customDataStr)) { try { customData = new JSONObject(customDataStr); } catch (JSONException e) { LOGE(TAG, "Failed to deserialize the custom data string: custom data= " + customDataStr); } } List<MediaTrack> mediaTracks = null; if (wrapper.getString(KEY_TRACKS_DATA) != null) { try { JSONArray jsonArray = new JSONArray(wrapper.getString(KEY_TRACKS_DATA)); mediaTracks = new ArrayList<MediaTrack>(); if (jsonArray.length() > 0) { for (int i = 0; i < jsonArray.length(); i++) { JSONObject jsonObj = (JSONObject) jsonArray.get(i); MediaTrack.Builder builder = new MediaTrack.Builder(jsonObj.getLong(KEY_TRACK_ID), jsonObj.getInt(KEY_TRACK_TYPE)); if (jsonObj.has(KEY_TRACK_NAME)) { builder.setName(jsonObj.getString(KEY_TRACK_NAME)); } if (jsonObj.has(KEY_TRACK_SUBTYPE)) { builder.setSubtype(jsonObj.getInt(KEY_TRACK_SUBTYPE)); } if (jsonObj.has(KEY_TRACK_CONTENT_ID)) { builder.setContentType(jsonObj.getString(KEY_TRACK_CONTENT_ID)); } if (jsonObj.has(KEY_TRACK_LANGUAGE)) { builder.setLanguage(jsonObj.getString(KEY_TRACK_LANGUAGE)); } if (jsonObj.has(KEY_TRACKS_DATA)) { builder.setCustomData(new JSONObject(jsonObj.getString(KEY_TRACKS_DATA))); } mediaTracks.add(builder.build()); } } } catch (JSONException e) { LOGE(TAG, "Failed to build media tracks from the wrapper bundle", e); } } MediaInfo.Builder mediaBuilder = new MediaInfo.Builder(wrapper.getString(KEY_URL)) .setStreamType(wrapper.getInt(KEY_STREAM_TYPE)).setContentType(wrapper.getString(KEY_CONTENT_TYPE)) .setMetadata(metaData).setCustomData(customData).setMediaTracks(mediaTracks); if (wrapper.containsKey(KEY_STREAM_DURATION) && wrapper.getLong(KEY_STREAM_DURATION) >= 0) { mediaBuilder.setStreamDuration(wrapper.getLong(KEY_STREAM_DURATION)); } return mediaBuilder.build(); }