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.taobao.weex.extend.module.actionsheet.WXActionSheet.java

private void prepareArguments() {
    Bundle bundle = getArguments();
    if (bundle != null) {
        titleText = bundle.getString(KEY_TITLE);
        messageText = bundle.getString(KEY_MESSAGE);
        actionItems = new ArrayList<>();
        ArrayList<String> items = bundle.getStringArrayList(KEY_ITEMS);
        if (items != null) {
            for (String item : items) {
                String[] splited = item.split(SEPARATOR);
                if (splited.length == 2) {
                    actionItems.add(Pair.create(splited[0], splited[1]));
                }/*from  w  ww .j a  v  a 2 s . c  o m*/
            }
        }
    }
}

From source file:com.luorrak.ouroboros.reply.ReplyCommentFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    isPosting = false;/*www . j  a v a2s  .  c  o m*/
    View view = inflater.inflate(R.layout.fragment_post_comment_activity, container, false);
    setActionBarTitle("Post a comment");

    networkHelper = new NetworkHelper();
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(getActivity());

    reply = new Reply();
    if (savedInstanceState == null) {
        reply.filePath = new ArrayList<>();
    } else {
        reply.filePath = savedInstanceState.getStringArrayList("filePath");
        for (String file : reply.filePath) {
            addAttachmentPreview(file, view);
        }
    }
    reply.fileName = new ArrayList<String>();

    resto = getActivity().getIntent().getStringExtra(Util.INTENT_THREAD_NO);
    boardName = getActivity().getIntent().getStringExtra(Util.INTENT_BOARD_NAME);
    replyNo = getActivity().getIntent().getStringExtra(Util.INTENT_REPLY_NO);

    EditText nameText = (EditText) view.findViewById(R.id.post_comment_editText_name);
    final EditText emailText = (EditText) view.findViewById(R.id.post_comment_editText_email);
    CheckBox sageBox = (CheckBox) view.findViewById(R.id.post_comment_checkBox_sage);
    EditText subjetText = (EditText) view.findViewById(R.id.post_comment_editText_subject);
    EditText commentText = (EditText) view.findViewById(R.id.post_comment_editText_comment);

    String defaultName = SettingsHelper.getDefaultName(getActivity());
    String defaultEmail = SettingsHelper.getDefaultEmail(getActivity());

    nameText.setText(sharedPreferences.getString(SaveReplyText.nameEditTextKey, defaultName));
    emailText.setText(sharedPreferences.getString(SaveReplyText.emailEditTextKey, defaultEmail));
    subjetText.setText(sharedPreferences.getString(SaveReplyText.subjectEditTextKey, ""));
    commentText.setText(sharedPreferences.getString(SaveReplyText.commentEditTextKey, ""));

    nameText.addTextChangedListener(new SaveReplyText(sharedPreferences, SaveReplyText.nameEditTextKey));
    emailText.addTextChangedListener(new SaveReplyText(sharedPreferences, SaveReplyText.emailEditTextKey));
    subjetText.addTextChangedListener(new SaveReplyText(sharedPreferences, SaveReplyText.subjectEditTextKey));
    commentText.addTextChangedListener(new SaveReplyText(sharedPreferences, SaveReplyText.commentEditTextKey));
    sageBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            reply.sage = isChecked;
        }
    });

    if (replyNo != null) {
        if (commentText.getText().toString().equals("")) {
            commentText.append(">>" + replyNo + "\n");
        } else {
            commentText.append("\n>>" + replyNo + "\n");
        }
    }

    commentText.requestFocus();

    setHasOptionsMenu(true);
    return view;
}

From source file:com.onebus.view.MainActivity.java

public void onPartialResults(Bundle partialResults) {
    ArrayList<String> nbest = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if (nbest.size() > 0) {
        // print("~" + Arrays.toString(nbest.toArray(new
        // String[0])));

    }//from  ww  w  . j  a va 2 s  . c  o  m
}

From source file:com.mohamnag.inappbilling.InAppBillingPlugin.java

private Error queryPurchases(String itemType) {
    Error ret = null;// ww w  . j a v  a  2  s. co  m
    jsLog("queryPurchases for type: " + itemType);

    try {
        Bundle ownedItems = iabService.getPurchases(3, cordova.getActivity().getPackageName(), itemType, null);

        int response = ownedItems.getInt("RESPONSE_CODE");
        if (response == BILLING_RESPONSE_RESULT_OK) {
            ArrayList<String> purchaseDataList = ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
            ArrayList<String> signatureList = ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
            String continuationToken = ownedItems.getString("INAPP_CONTINUATION_TOKEN");

            jsLog("Got purchases: " + purchaseDataList.size());
            jsLog("Got signatures: " + signatureList.size());

            for (int i = 0; i < purchaseDataList.size(); ++i) {
                String purchaseData = purchaseDataList.get(i);
                String signature = signatureList.get(i);

                try {
                    Purchase purchase = new Purchase(purchaseData, signature);

                    if (base64EncodedPublicKey != null
                            && !Security.verifyPurchase(base64EncodedPublicKey, purchaseData, signature)) {

                        jsLog("Signature verification failed: " + purchaseData + " signature: " + signature);
                    } else {
                        jsLog("Purchase loaded for: " + purchase.getSku());

                        // add the purchase to the inventory
                        myInventory.addPurchase(purchase);
                    }
                } catch (JSONException e) {
                    ret = new Error(ERR_JSON_CONVERSION_FAILED, e.getMessage());
                }
            }
        }

        // TODO: if continuationToken != null, call getPurchases again 
        // and pass in the token to retrieve more items
    } catch (RemoteException ex) {
        Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex);
        ret = new Error(ERR_LOAD_RECEIPTS, ex.getMessage());
    }

    return ret;
}

From source file:com.nokia.example.pepperfarm.iap.Payment.java

/**
 * Check the products that we have already purchased
 *//*from w  ww . j a  v  a2 s .c  om*/
public void getPurchases(boolean ignoreLifeCycleCheck) {

    if (!isBillingAvailable())
        return;

    if (ignoreLifeCycleCheck == false) {
        if (purchases_asked) {
            Log.i("getPurchases", "Restorables already asked.");
            return;
        }
    }

    MainScreenPepperListFragment.getpeppers.setVisibility(View.INVISIBLE);
    MainScreenPepperListFragment.fetch_peppers_progressbar.setVisibility(View.VISIBLE);
    MainScreenPepperListFragment.fetching_peppers.setVisibility(View.VISIBLE);

    AsyncTask<Void, String, Void> restoreTask = new AsyncTask<Void, String, Void>() {

        @Override
        protected Void doInBackground(Void... params) {
            ArrayList<String> productIdArray = new ArrayList<String>(Content.ITEM_MAP.keySet());
            Bundle productBundle = new Bundle();
            productBundle.putStringArrayList("ITEM_ID_LIST", productIdArray);

            try {
                Bundle purchases = npay.getPurchases(API_VERSION, activity.getPackageName(), ITEM_TYPE_INAPP,
                        productBundle, null);
                Log.i("getPurchases",
                        "GET PURCHASES RESPONSE CODE: " + purchases.getInt("RESPONSE_CODE", RESULT_ERR));

                if (purchases.getInt("RESPONSE_CODE", RESULT_ERR) == RESULT_OK) {

                    ArrayList<String> purchaseDataList = purchases
                            .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                    for (String purchaseData : purchaseDataList) {
                        parsePurchaseData(purchaseData);
                    }
                    purchases_asked = true;
                } else {
                    Log.e("getPurchases", "GET PURCHASES - response was not ok: Result was: "
                            + purchases.getInt("RESPONSE_CODE", RESULT_ERR));
                }

            } catch (JSONException e) {
                Log.e("getPurchases", "PURCHASE DATA PARSING EXCEPTION: " + e.getMessage(), e);
            } catch (RemoteException e) {
                Log.e("getPurchases", "EXCEPTION: " + e.getMessage(), e);
            }
            return null;
        }

        private void parsePurchaseData(String purchaseData) throws JSONException {

            Purchase purchase = new Purchase(purchaseData);

            Product p = Content.ITEM_MAP.get(purchase.getProductId());

            if (p != null) {
                p.setPurchased(purchase);
                Log.i("getPurchases", "Restoring product " + purchase.getProductId() + " Purchase token: "
                        + purchase.getToken());
            } else {
                Log.i("getPurchases",
                        "Unable to restore product " + purchase.getProductId() + ". Product not found.");
            }

        }

        @Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            MainScreenPepperListFragment.getpeppers.setVisibility(View.VISIBLE);
            MainScreenPepperListFragment.fetch_peppers_progressbar.setVisibility(View.GONE);
            MainScreenPepperListFragment.fetching_peppers.setVisibility(View.GONE);

            if (ProductListFragment.purchaseListAdapter != null) {
                ProductListFragment.purchaseListAdapter.notifyDataSetChanged();
            }
            if (MainScreenPepperListFragment.reference.adapter != null) {
                MainScreenPepperListFragment.reference.adapter.notifyDataSetChanged();
            }
        }

    };
    restoreTask.execute();
}

From source file:com.wizardsofm.deskclock.alarms.AlarmActivity.java

@Override
public void onResults(Bundle data) {

    resumeCounting = false;//w  w w .j  a v  a  2  s.  c  om

    ArrayList<String> matches = data.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);

    makeText(this, getResources().getString(R.string.you_said) + matches.get(0), Toast.LENGTH_SHORT).show();

    if (matches.get(0).toUpperCase().contains("SHUTUP".toUpperCase())
            || (matches.get(0).toUpperCase().contains("SHUT UP".toUpperCase()))) {
        snooze();
        speech.cancel();
    } else if (matches.get(0).toUpperCase().contains("STOP".toUpperCase())) {
        dismiss();
        speech.cancel();
    } else {
        speech.cancel();
        speech.startListening(intent);
        resumeCounting = true;
    }
}

From source file:cn.jasonlv.siri.activity.MainActivity.java

@Override
public void onPartialResults(Bundle partialResults) {
    ArrayList<String> nbest = partialResults.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
    if (nbest.size() > 0) {
        print("~" + Arrays.toString(nbest.toArray(new String[0])));
        //txtResult.setText(nbest.get(0));
    }//from   w  ww  .j ava2 s . co m
}

From source file:com.mohamnag.inappbilling.InAppBillingPlugin.java

/**
 * Loads the product details from play store and puts them in inventory,
 * will reload the product if they have been already loaded before.
 *
 * @param querySkus//from  w w w  . ja  v a2 s .  c o m
 * @param itemType
 * @param callbackContext
 * @throws RemoteException
 */
private Error querySkuDetails(Bundle querySkus, String itemType) {
    Error ret = null;

    try {
        Bundle skuDetailsInapp = iabService.getSkuDetails(3, cordova.getActivity().getPackageName(), itemType,
                querySkus);

        int response = skuDetailsInapp.getInt("RESPONSE_CODE");
        if (response == BILLING_RESPONSE_RESULT_OK) {
            ArrayList<String> responseList = skuDetailsInapp.getStringArrayList("DETAILS_LIST");

            for (String thisResponse : responseList) {
                try {
                    SkuDetails d = new SkuDetails(itemType, thisResponse);
                    jsLog("Got sku details: " + d);

                    myInventory.addSkuDetails(d);
                } catch (JSONException ex) {
                    jsLog("JSONException: " + ex.getMessage());
                }
            }
        } else {
            ret = new Error(ERR_LOAD_INVENTORY, "Cant load product details. Responce code: " + response);
        }
    } catch (RemoteException ex) {
        Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex);

        ret = new Error(ERR_LOAD_INVENTORY, ex.getMessage());
    }

    return ret;
}

From source file:io.teak.sdk.GooglePlay.java

private JSONObject querySkuDetails(String itemType, String sku) {
    try {//  ww  w  . j a v a2s.  co  m
        ArrayList<String> skuList = new ArrayList<>();
        skuList.add(sku);
        Class<?> cls = Class.forName("com.android.vending.billing.IInAppBillingService");
        Method m = cls.getMethod("getSkuDetails", int.class, String.class, String.class, Bundle.class);

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

        Bundle skuDetails = (Bundle) m.invoke(mService, 3, mContext.getPackageName(), itemType, querySkus);

        if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
            int response = getResponseCodeFromBundle(skuDetails);
            if (response != BILLING_RESPONSE_RESULT_OK) {
                Log.e(LOG_TAG, "getSkuDetails() failed: " + response);
                return null;
            } else {
                Log.e(LOG_TAG, "getSkuDetails() returned a bundle with neither an error nor a detail list.");
                return null;
            }
        }

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

        if (responseList != null && responseList.size() == 1) {
            JSONObject ret = new JSONObject(responseList.get(0));
            if (Teak.isDebug) {
                Log.d(LOG_TAG, "SKU Details: " + ret.toString(2));
            }
            return ret;
        } else {
            Log.e(LOG_TAG, "Mismatched input/output length for getSkuDetails().");
        }
    } catch (Exception e) {
        Log.e(LOG_TAG, "Reflection error: " + Log.getStackTraceString(e));
        Teak.sdkRaven.reportException(e);
    }

    return null;
}

From source file:ir.aarani.bazaar.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  va 2  s  .c o  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>();
                List<String> detailsList = skuDetails.getStringArrayList(Constants.DETAILS_LIST);
                if (detailsList != null)
                    for (String responseLine : detailsList) {
                        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, "Failed to call getSkuDetails", e);
            if (eventHandler != null)
                eventHandler.onBillingError(Constants.BILLING_ERROR_SKUDETAILS_FAILED, e);
        }
    }
    return null;
}