List of usage examples for android.os Bundle putStringArrayList
@Override public void putStringArrayList(@Nullable String key, @Nullable ArrayList<String> value)
From source file:com.pileproject.drive.programming.visual.activity.ProgrammingActivity.java
private void showLoadProgramDialog(ArrayList<String> programs, boolean isSample) { Bundle args = new Bundle(); args.putBoolean(KEY_IS_SAMPLE, isSample); args.putStringArrayList(KEY_SAMPLE_PROGRAMS, programs); new AlertDialogFragment.Builder(this).setRequestCode(DIALOG_REQUEST_CODE_PROGRAM_LIST) .setTitle(R.string.programming_loadProgram).setItems(programs.toArray(new String[programs.size()])) .setNegativeButtonLabel(android.R.string.cancel).setParams(args).show(); }
From source file:com.thunder.iap.IAPActivity.java
/** * * @param skuList the list of available skus * @param listener/*w ww. j a v a 2 s. co m*/ */ 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:org.openbmap.unifiedNlp.Geocoder.OnlineProvider.java
/** * Queries location for list of wifis// ww w. j a v a 2 s . c om */ @SuppressWarnings("unchecked") @Override public void getLocation(List<ScanResult> wifisList, List<Cell> cellsList) { ArrayList<String> wifis = new ArrayList<>(); if (wifisList != null) { // Generates a list of wifis from scan results for (ScanResult r : wifisList) { if ((r.BSSID != null) & !(r.SSID.endsWith("_nomap"))) { wifis.add(r.BSSID); } } Log.i(TAG, "Using " + wifis.size() + " wifis for geolocation"); } else Log.i(TAG, "No wifis supplied for geolocation"); new AsyncTask<Object, Void, JSONObject>() { @Override protected JSONObject doInBackground(Object... params) { if (params == null) { throw new IllegalArgumentException("Wifi list was null"); } mWifiQuery = (ArrayList<String>) params[0]; mCellQuery = new ArrayList<>(); for (Cell temp : (List<Cell>) params[1]) { mCellQuery.add(temp.toString()); } Random r = new Random(); int idx = r.nextInt(3); final String balancer = String.format(REQUEST_URL, new String[] { "a", "b", "c" }[idx]); if (mDebug) { Log.v(TAG, "Using balancer " + balancer); } return loadJSON(balancer, (ArrayList<String>) params[0], (List<Cell>) params[1]); } @Override protected void onPostExecute(JSONObject jsonData) { if (jsonData == null) { Log.e(TAG, "JSON data was null"); return; } try { Log.i(TAG, "JSON response: " + jsonData.toString()); String source = jsonData.getString("source"); JSONObject location = jsonData.getJSONObject("location"); Double lat = location.getDouble("lat"); Double lon = location.getDouble("lng"); Long acc = jsonData.getLong("accuracy"); Location result = new Location(TAG); result.setLatitude(lat); result.setLongitude(lon); result.setAccuracy(acc); result.setTime(System.currentTimeMillis()); Bundle b = new Bundle(); b.putString("source", source); b.putStringArrayList("bssids", mWifiQuery); b.putStringArrayList("cells", mCellQuery); result.setExtras(b); if (plausibleLocationUpdate(result)) { setLastLocation(result); setLastFix(System.currentTimeMillis()); mListener.onLocationReceived(result); } else { Log.i(TAG, "Strange location, ignoring"); } } catch (JSONException e) { Log.e(TAG, "Error parsing JSON:" + e.getMessage()); } } public JSONObject loadJSON(String url, ArrayList<String> wifiParams, List<Cell> cellParams) { // Creating JSON Parser instance JSONParser jParser = new JSONParser(); JSONObject params = buildParams(wifiParams, cellParams); return jParser.getJSONFromUrl(url, params); } /** * Builds a JSON array with cell and wifi query * @param wifis ArrayList containing bssids * @param cells * @return JSON object */ public JSONObject buildParams(ArrayList<String> wifis, List<Cell> cells) { JSONObject root = new JSONObject(); try { // add wifi objects JSONArray jsonArray = new JSONArray(); if (mDebug) { JSONObject object = new JSONObject(); object.put("debug", "1"); jsonArray.put(object); } for (String s : wifis) { JSONObject object = new JSONObject(); object.put("macAddress", s); object.put("signalStrength", "-54"); jsonArray.put(object); } if (jsonArray.length() > 0) { root.put("wifiAccessPoints", jsonArray); } // add cell objects jsonArray = new JSONArray(); for (Cell s : cells) { JSONObject object = new JSONObject(); object.put("cellId", s.cellId); object.put("locationAreaCode", s.area); object.put("mobileCountryCode", s.mcc); object.put("mobileNetworkCode", s.mnc); jsonArray.put(object); } if (jsonArray.length() > 0) { root.put("cellTowers", jsonArray); } } catch (JSONException e) { e.printStackTrace(); } Log.v(TAG, "Query param: " + root.toString()); return root; } }.execute(wifis, cellsList); }
From source file:com.anjlab.android.iab.v3.BillingProcessor.java
private SkuDetails getSkuDetails(String productId, String purchaseType) { if (billingService != null) { try {//from www .ja v a 2 s . c om ArrayList<String> skuList = new ArrayList<String>(); skuList.add(productId); Bundle products = new Bundle(); products.putStringArrayList(Constants.PRODUCTS_LIST, skuList); 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) { for (String responseLine : skuDetails.getStringArrayList(Constants.DETAILS_LIST)) { JSONObject object = new JSONObject(responseLine); String responseProductId = object.getString(Constants.RESPONSE_PRODUCT_ID); if (productId.equals(responseProductId)) return new SkuDetails(object); } } else { if (eventHandler != null) eventHandler.onBillingError(response, null); Log.e(LOG_TAG, String.format("Failed to retrieve info for %s: error %d", productId, response)); } } catch (Exception e) { Log.e(LOG_TAG, String.format("Failed to call getSkuDetails %s", e.toString())); } } return null; }
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;// w w w.j a v a 2s . c om try { 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:org.tomahawk.tomahawk_android.dialogs.FakeContextMenuDialog.java
/** * If the user clicks on a fakeContextItem, handle what should be done here *//*from w w w. j av a 2s . c om*/ private void onFakeContextItemSelected(int position) { DatabaseHelper dataSource = DatabaseHelper.getInstance(); ArrayList<Query> queries = new ArrayList<Query>(); PlaybackService playbackService = ((TomahawkMainActivity) getActivity()).getPlaybackService(); String menuItemTitle = (String) mMenuAdapter.getItem(position); if (mTomahawkListItem instanceof SocialAction) { mTomahawkListItem = ((SocialAction) mTomahawkListItem).getTargetObject(); } if (menuItemTitle.equals(getString(R.string.fake_context_menu_delete))) { if (mTomahawkListItem instanceof UserPlaylist) { dataSource.deleteUserPlaylist(((UserPlaylist) mTomahawkListItem).getId()); } else if (mTomahawkListItem instanceof Query && mUserPlaylist != null) { dataSource.deleteQueryInUserPlaylist(mUserPlaylist.getId(), mListItemPosition); } else if (playbackService != null && mFromPlaybackFragment && mTomahawkListItem instanceof Query) { if (playbackService.getCurrentTrack().getCacheKey().equals(mTomahawkListItem.getCacheKey())) { boolean wasPlaying = playbackService.isPlaying(); if (wasPlaying) { playbackService.pause(); } if (playbackService.getCurrentPlaylist().peekNextQuery() != null) { playbackService.next(); if (wasPlaying) { playbackService.start(); } } else if (playbackService.getCurrentPlaylist().peekPreviousQuery() != null) { playbackService.previous(); if (wasPlaying) { playbackService.start(); } } } playbackService.deleteQuery((Query) mTomahawkListItem); } } else if (menuItemTitle.equals(getString(R.string.fake_context_menu_play))) { if (mFromPlaybackFragment) { if (playbackService != null && mTomahawkListItem instanceof Query && playbackService.getCurrentPlaylist().getCurrentQuery() != null) { if (playbackService.getCurrentPlaylist().getCurrentQuery().getCacheKey() .equals(mTomahawkListItem.getCacheKey())) { if (!playbackService.isPlaying()) { playbackService.start(); } } else { playbackService.setCurrentQueryIndex(mListItemPosition); playbackService.start(); } } } else { UserPlaylist playlist; if (mTomahawkListItem instanceof Query) { if (mAlbum != null) { queries = AdapterUtils.getAlbumTracks(mAlbum, mCollection); } else if (mArtist != null) { queries = AdapterUtils.getArtistTracks(mArtist, mCollection); } else if (mUserPlaylist != null) { queries = mUserPlaylist.getQueries(); } else { queries.add((Query) mTomahawkListItem); } playlist = UserPlaylist.fromQueryList(DatabaseHelper.CACHED_PLAYLIST_ID, DatabaseHelper.CACHED_PLAYLIST_NAME, queries, mListItemPosition); } else if (mTomahawkListItem instanceof UserPlaylist) { playlist = (UserPlaylist) mTomahawkListItem; } else { playlist = UserPlaylist.fromQueryList(DatabaseHelper.CACHED_PLAYLIST_ID, DatabaseHelper.CACHED_PLAYLIST_NAME, mTomahawkListItem.getQueries()); } if (playbackService != null) { playbackService.setCurrentPlaylist(playlist); playbackService.start(); } FragmentUtils.showHub(getActivity(), getActivity().getSupportFragmentManager(), FragmentUtils.HUB_ID_PLAYBACK); } } else if (menuItemTitle.equals(getString(R.string.fake_context_menu_playaftercurrenttrack))) { if (mTomahawkListItem instanceof Artist) { Artist artist = (Artist) mTomahawkListItem; queries = AdapterUtils.getArtistTracks(artist, mCollection); } else if (mTomahawkListItem instanceof Album) { Album album = (Album) mTomahawkListItem; queries = AdapterUtils.getAlbumTracks(album, mCollection); } else { queries = mTomahawkListItem.getQueries(); } if (playbackService != null) { if (playbackService.getCurrentPlaylist() != null) { playbackService.addQueriesToCurrentPlaylist( playbackService.getCurrentPlaylist().getCurrentQueryIndex() + 1, queries); } else { playbackService.addQueriesToCurrentPlaylist(queries); } } } else if (menuItemTitle.equals(getString(R.string.fake_context_menu_appendtoplaybacklist))) { if (mTomahawkListItem instanceof Artist) { Artist artist = (Artist) mTomahawkListItem; queries = AdapterUtils.getArtistTracks(artist, mCollection); } else if (mTomahawkListItem instanceof Album) { Album album = (Album) mTomahawkListItem; queries = AdapterUtils.getAlbumTracks(album, mCollection); } else { queries = mTomahawkListItem.getQueries(); } if (playbackService != null) { playbackService.addQueriesToCurrentPlaylist(queries); } } else if (menuItemTitle.equals(getString(R.string.fake_context_menu_addtoplaylist))) { if (mTomahawkListItem instanceof Artist) { Artist artist = (Artist) mTomahawkListItem; queries = AdapterUtils.getArtistTracks(artist, mCollection); } else if (mTomahawkListItem instanceof Album) { Album album = (Album) mTomahawkListItem; queries = AdapterUtils.getAlbumTracks(album, mCollection); } else { queries = mTomahawkListItem.getQueries(); } ArrayList<String> queryKeys = new ArrayList<String>(); for (Query query : queries) { queryKeys.add(query.getCacheKey()); } ChooseUserPlaylistDialog dialog = new ChooseUserPlaylistDialog(); Bundle args = new Bundle(); args.putStringArrayList(TomahawkFragment.TOMAHAWK_QUERYKEYSARRAY_KEY, queryKeys); dialog.setArguments(args); dialog.show(getActivity().getSupportFragmentManager(), null); } else if (menuItemTitle.equals(getString(R.string.menu_item_go_to_album))) { FragmentUtils.replace(getActivity(), getActivity().getSupportFragmentManager(), TracksFragment.class, mTomahawkListItem.getAlbum().getCacheKey(), TomahawkFragment.TOMAHAWK_ALBUM_KEY, mCollection); } else if (menuItemTitle.equals(getActivity().getString(R.string.menu_item_go_to_artist))) { FragmentUtils.replace(getActivity(), getActivity().getSupportFragmentManager(), AlbumsFragment.class, mTomahawkListItem.getArtist().getCacheKey(), TomahawkFragment.TOMAHAWK_ARTIST_KEY, mCollection); } else if (menuItemTitle.equals(getString(R.string.fake_context_menu_love_track)) || menuItemTitle.equals(getString(R.string.fake_context_menu_unlove_track))) { CollectionManager.getInstance().toggleLovedItem((Query) mTomahawkListItem); } }
From source file:com.friedran.appengine.dashboard.client.AppEngineDashboardClient.java
/** * Send an authenticated GetApplications request asynchronously and return its results to the given callback. *///from w w w . j a v a2 s .c o m public void executeGetApplications(final PostExecuteCallback postGetApplicationsCallback) { new AuthenticatedRequestTask("https://appengine.google.com/", new AuthenticatedRequestTaskBackgroundCallback() { @Override public Bundle run(final HttpEntity httpResponse) { Bundle result = new Bundle(); try { mLastRetrievedApplications = AppEngineParserUtils .getApplicationIDs(httpResponse.getContent()); result.putStringArrayList(KEY_APPLICATIONS, mLastRetrievedApplications); result.putBoolean(KEY_RESULT, true); } catch (IOException e) { LogUtils.e("AppEngineDashboardClient", "Failed parsing the GetApplications response", e); result.putBoolean(KEY_RESULT, false); } return result; } }, postGetApplicationsCallback).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); }
From source file:com.money.manager.ex.fragment.AccountFragment.java
private Bundle prepareArgsForChildFragment() { // compose selection and sort ArrayList<String> selection = new ArrayList<String>(); selection.add("(" + QueryAllData.ACCOUNTID + "=" + Integer.toString(mAccountId) + " OR " + QueryAllData.ToAccountID + "=" + Integer.toString(mAccountId) + ")"); if (currencyUtils.getShowTransaction().equalsIgnoreCase(getString(R.string.last7days))) { selection.add("(julianday(date('now')) - julianday(" + QueryAllData.Date + ") <= 7)"); } else if (currencyUtils.getShowTransaction().equalsIgnoreCase(getString(R.string.last15days))) { selection.add("(julianday(date('now')) - julianday(" + QueryAllData.Date + ") <= 14)"); } else if (currencyUtils.getShowTransaction().equalsIgnoreCase(getString(R.string.current_month))) { selection.add(// w ww. jav a 2 s . co m QueryAllData.Month + "=" + Integer.toString(Calendar.getInstance().get(Calendar.MONTH) + 1)); selection.add(QueryAllData.Year + "=" + Integer.toString(Calendar.getInstance().get(Calendar.YEAR))); } else if (currencyUtils.getShowTransaction().equalsIgnoreCase(getString(R.string.last3months))) { selection.add("(julianday(date('now')) - julianday(" + QueryAllData.Date + ") <= 90)"); } else if (currencyUtils.getShowTransaction().equalsIgnoreCase(getString(R.string.last6months))) { selection.add("(julianday(date('now')) - julianday(" + QueryAllData.Date + ") <= 180)"); } else if (currencyUtils.getShowTransaction().equalsIgnoreCase(getString(R.string.current_year))) { selection.add(QueryAllData.Year + "=" + Integer.toString(Calendar.getInstance().get(Calendar.YEAR))); } // create a bundle to returns Bundle args = new Bundle(); args.putStringArrayList(AllDataFragment.KEY_ARGUMENTS_WHERE, selection); args.putString(AllDataFragment.KEY_ARGUMENTS_SORT, QueryAllData.Date + " DESC, " + QueryAllData.ID + " DESC"); return args; }
From source file:org.sufficientlysecure.keychain.ui.CreateKeyActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putString(EXTRA_NAME, mName); outState.putString(EXTRA_EMAIL, mEmail); outState.putStringArrayList(EXTRA_ADDITIONAL_EMAILS, mAdditionalEmails); outState.putParcelable(EXTRA_PASSPHRASE, mPassphrase); outState.putBoolean(EXTRA_FIRST_TIME, mFirstTime); outState.putBoolean(EXTRA_CREATE_SECURITY_TOKEN, mCreateSecurityToken); outState.putByteArray(EXTRA_SECURITY_TOKEN_AID, mSecurityTokenAid); outState.putParcelable(EXTRA_SECURITY_TOKEN_PIN, mSecurityTokenPin); outState.putParcelable(EXTRA_SECURITY_TOKEN_ADMIN_PIN, mSecurityTokenAdminPin); }
From source file:de.eidottermihi.rpicheck.activity.CustomCommandActivity.java
/** * Opens the command dialog./*from ww w . j av a2 s . c om*/ * * @param keyPassphrase nullable: key passphrase */ private void openCommandDialog(final long commandId, final String keyPassphrase) { final CommandBean command = deviceDb.readCommand(commandId); final ArrayList<String> dynamicPlaceholders = parseDynamicPlaceholders(command.getCommand()); if (!dynamicPlaceholders.isEmpty()) { // need to get replacements for dynamic placeholders first DialogFragment placeholderDialog = new CommandPlaceholdersDialog(); Bundle args2 = new Bundle(); args2.putStringArrayList(CommandPlaceholdersDialog.ARG_PLACEHOLDERS, dynamicPlaceholders); args2.putSerializable(CommandPlaceholdersDialog.ARG_COMMAND, command); args2.putString(CommandPlaceholdersDialog.ARG_PASSPHRASE, keyPassphrase); placeholderDialog.setArguments(args2); placeholderDialog.show(getSupportFragmentManager(), "placeholders"); return; } parseNonPromptingAndShow(keyPassphrase, command); }