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.seregil13.literarytracker.lightnovel.LightNovelEditFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Bundle arguments = getArguments();
    this.mCreateOrEdit = (Mode) arguments.getSerializable(CREATE_OR_EDIT_KEY);
    if (this.mCreateOrEdit == null) {
        this.mCreateOrEdit = Mode.CREATE;
    }//from ww w  .  j a v a2s  . c  o m

    switch (this.mCreateOrEdit) {
    case CREATE:
        this.mTitle = "";
        this.mAuthor = "";
        this.mDescription = "";
        this.mCompleted = "false";
        this.mTranslatorSite = "";
        this.mGenres = new ArrayList<>();
        break;
    case EDIT:
        this.mId = arguments.getInt(JsonKeys.ID.toString());
        this.mTitle = arguments.getString(JsonKeys.TITLE.toString());
        this.mAuthor = arguments.getString(JsonKeys.AUTHOR.toString());
        this.mDescription = arguments.getString(JsonKeys.DESCRIPTION.toString());
        this.mCompleted = arguments.getString(JsonKeys.COMPLETED.toString());
        this.mTranslatorSite = arguments.getString(JsonKeys.TRANSLATOR_SITE.toString());
        this.mGenres = arguments.getStringArrayList(JsonKeys.GENRES.toString());
        break;
    }
}

From source file:com.cwp.cmoneycharge.activity.AddPayActivity.java

@Override
public void onResults(Bundle results) {
    //?// w  w  w . ja v a 2 s. c om
    status = STATUS_None;
    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 {
        Toast.makeText(AddPayActivity.this, "origin_result=\n" + new JSONObject(json_res).toString(4),
                Toast.LENGTH_SHORT).show();
    } catch (Exception e) {
        Toast.makeText(AddPayActivity.this, "origin_result=[warning: bad json]\n" + json_res,
                Toast.LENGTH_SHORT).show();
    }
}

From source file:com.abplus.surroundcalc.billing.BillingHelper.java

int querySkuDetails(Inventory inv, List<String> moreSkus) throws RemoteException, JSONException {
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(ITEM_TYPE_INAPP));
    if (moreSkus != null)
        skuList.addAll(moreSkus);/*from   w w  w .j  ava  2s. c o  m*/

    if (skuList.size() == 0) {
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = connection.getSkuDetails(querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            return response;
        } else {
            return HELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        SkuDetails d = new SkuDetails(thisResponse);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:org.kontalk.billing.GoogleBillingService.java

int querySkuDetails(String itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);/*  ww w .  ja va  2 s.c  o m*/
            }
        }
    }

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), itemType, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        ProductDetails d = new ProductDetails(itemType, thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:com.turbulenz.turbulenz.googlepayment.java

void threadQueryProduct(final String sku, final long context) {
    ArrayList skuList = new ArrayList();
    skuList.add(sku);/*from  ww w.  j  ava  2s .co m*/
    Bundle productQueryBundle = new Bundle();
    productQueryBundle.putStringArrayList("ITEM_ID_LIST", skuList);

    Bundle skuDetails;
    try {
        skuDetails = mService.getSkuDetails(3, mActivity.getPackageName(), ITEM_TYPE_INAPP, productQueryBundle);
    } catch (RemoteException e) {
        _error("threadQueryProduct: remote exception: " + e);
        e.printStackTrace();
        sendProductInfoError(context, sku);
        return;
    }

    int response = getResponseCodeFromBundle(skuDetails);
    if (BILLING_RESPONSE_RESULT_OK != response) {
        _log("threadQueryProduct: bad response from getSkuDetails: " + response);
        sendProductInfoError(context, sku);
        return;
    }

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        _log("threadQueryProduct: bundle doens't contain list");
        sendProductInfoError(context, sku);
        return;
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    if (1 != responseList.size()) {
        _log("threadQueryProduct: repsonse list has unexpected length: " + responseList.size());
        sendProductInfoError(context, sku);
        return;
    }

    String responseString = responseList.get(0);
    try {
        JSONObject o = new JSONObject(responseString);
        final String _sku = o.getString("productId");
        final String title = o.getString("title");
        final String description = o.getString("description");

        // TODO: something with price
        final String price = o.getString("price");

        // TOOD: check _sku == sku

        sendProductInfo(context, sku, title, description, price);
    } catch (JSONException e) {
        _error("threadQueryProduct: failed parsing JSON");
        sendProductInfoError(context, sku);
    }
}

From source file:com.abplus.surroundcalc.billing.BillingHelper.java

int queryPurchases(Inventory inv) throws JSONException, RemoteException {
    boolean verificationFailed = false;
    String continueToken = null;/*from ww w  . ja  va 2 s .c  om*/

    do {
        Bundle ownedItems = connection.getPurchases(continueToken);

        int response = getResponseCodeFromBundle(ownedItems);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            return response;
        }
        if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
            return HELPER_BAD_RESPONSE;
        }

        ArrayList<String> purchaseDataList = ownedItems.getStringArrayList(RESPONSE_INAPP_PURCHASE_DATA_LIST);
        ArrayList<String> signatureList = ownedItems.getStringArrayList(RESPONSE_INAPP_SIGNATURE_LIST);

        for (int i = 0; i < purchaseDataList.size(); ++i) {
            String purchaseData = purchaseDataList.get(i);
            String signature = signatureList.get(i);
            if (security.verifyPurchase(purchaseData, signature)) {
                Purchase purchase = new Purchase(purchaseData, signature);
                inv.addPurchase(purchase);
            } else {
                verificationFailed = true;
            }
        }

        continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? HELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
}

From source file:com.soomla.store.billing.nokia.NokiaIabHelper.java

/**
 * Queries a chunk of SKU details to prevent Google's 20 items bug.
 *
 * @throws RemoteException/* www.j  a va2  s.c o  m*/
 * @throws JSONException
 */
private int querySkuDetailsChunk(String itemType, IabInventory inv, ArrayList<String> chunkSkuList)
        throws RemoteException, JSONException {
    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, chunkSkuList);
    Bundle skuDetails = mService.getProductDetails(3, SoomlaApp.getAppContext().getPackageName(), itemType,
            querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != IabResult.BILLING_RESPONSE_RESULT_OK) {
            SoomlaUtils.LogDebug(TAG, "querySkuDetailsChunk() failed: " + IabResult.getResponseDesc(response));
            return response;
        } else {
            SoomlaUtils.LogError(TAG,
                    "querySkuDetailsChunk() returned a bundle with neither an error nor a detail list.");
            return IabResult.IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        IabSkuDetails d = new IabSkuDetails(itemType, thisResponse);
        SoomlaUtils.LogDebug(TAG, "Got sku details: " + d);
        inv.addSkuDetails(d);
    }

    return IabResult.BILLING_RESPONSE_RESULT_OK;
}

From source file:com.evolup.test.IAPTest01.util.IabHelper.java

int querySkuDetails(Inventory inv, List<String> moreSkus) throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus());
    if (moreSkus != null)
        skuList.addAll(moreSkus);/* ww w.  j  a  va 2 s .c  o m*/

    if (skuList.size() == 0) {
        logDebug("queryPrices: nothing to do because there are no SKUs.");
        return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(3, mContext.getPackageName(), ITEM_TYPE_INAPP, querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getSkuDetails() failed: " + getResponseDesc(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        SkuDetails d = new SkuDetails(thisResponse);
        logDebug("Got sku details: " + d);
        inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
}

From source file:com.github.jberkel.pay.me.IabHelper.java

private int querySkuDetails(ItemType itemType, Inventory inv, List<String> moreSkus)
        throws RemoteException, JSONException {
    logDebug("Querying SKU details.");
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(itemType));
    if (moreSkus != null) {
        for (String sku : moreSkus) {
            if (!skuList.contains(sku)) {
                skuList.add(sku);/*from   w  w w  . ja v a  2s  .  c  om*/
            }
        }
    }
    if (skuList.isEmpty()) {
        logDebug("querySkuDetails: nothing to do because there are no SKUs.");
        return OK.code;
    }

    // TODO: check for 20 SKU limit + add batching ?
    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = mService.getSkuDetails(API_VERSION, mContext.getPackageName(), itemType.toString(),
            querySkus);
    if (skuDetails == null)
        return IABHELPER_BAD_RESPONSE.code;

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != OK.code) {
            logWarn("getSkuDetails() failed: " + getDescription(response));
            return response;
        } else {
            logError("getSkuDetails() returned a bundle with neither an error nor a detail list.");
            return IABHELPER_BAD_RESPONSE.code;
        }
    }
    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);
    for (String json : responseList) {
        inv.addSkuDetails(new SkuDetails(json));
    }
    return OK.code;
}

From source file:com.soomla.store.billing.google.GoogleIabHelper.java

/**
 * Queries a chunk of SKU details to prevent Google's 20 items bug.
 *
 * @throws RemoteException//from   w w w .  ja v  a  2  s .c  om
 * @throws JSONException
 */
private int querySkuDetailsChunk(String itemType, IabInventory inv, ArrayList<String> chunkSkuList)
        throws RemoteException, JSONException {
    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, chunkSkuList);
    Bundle skuDetails = mService.getSkuDetails(3, SoomlaApp.getAppContext().getPackageName(), itemType,
            querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
        int response = getResponseCodeFromBundle(skuDetails);
        if (response != IabResult.BILLING_RESPONSE_RESULT_OK) {
            SoomlaUtils.LogDebug(TAG, "querySkuDetailsChunk() failed: " + IabResult.getResponseDesc(response));
            return response;
        } else {
            SoomlaUtils.LogError(TAG,
                    "querySkuDetailsChunk() returned a bundle with neither an error nor a detail list.");
            return IabResult.IABHELPER_BAD_RESPONSE;
        }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
        IabSkuDetails d = new IabSkuDetails(itemType, thisResponse);
        SoomlaUtils.LogDebug(TAG, "Got sku details: " + d);
        inv.addSkuDetails(d);
    }

    return IabResult.BILLING_RESPONSE_RESULT_OK;
}