Example usage for android.os Bundle get

List of usage examples for android.os Bundle get

Introduction

In this page you can find the example usage for android.os Bundle get.

Prototype

@Nullable
public Object get(String key) 

Source Link

Document

Returns the entry with the given key as an object.

Usage

From source file:com.canappi.connector.yp.yhere.RestaurantView.java

public void viewDidLoad() {

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        Set<String> keys = extras.keySet();
        for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
            String key = iter.next();
            Class c = SearchView.class;
            try {
                Field f = c.getDeclaredField(key);
                Object extra = extras.get(key);
                String value = extra.toString();
                f.set(this, extras.getString(value));
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();/*  w w  w . jav a  2s  .c  o  m*/
            } catch (NoSuchFieldException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    } else {

    }

    restaurantViewIds = new HashMap();
    restaurantViewValues = new HashMap();

    isUserDefault = false;

    resultsListView = (ListView) findViewById(R.id.resultsTable);
    resultsAdapter = new ResultsEfficientAdapter(this);

    businessNameArray = new ArrayList<String>();

    latitudeArray = new ArrayList<String>();

    longitudeArray = new ArrayList<String>();

    listingIdArray = new ArrayList<String>();

    phoneArray = new ArrayList<String>();

    callArray = new ArrayList<String>();

    streetArray = new ArrayList<String>();

    cityArray = new ArrayList<String>();
    resultsListView.setAdapter(resultsAdapter);
    didSelectViewController();

}

From source file:com.canappi.connector.yp.yhere.TheaterView.java

public void viewDidLoad() {

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        Set<String> keys = extras.keySet();
        for (Iterator<String> iter = keys.iterator(); iter.hasNext();) {
            String key = iter.next();
            Class c = SearchView.class;
            try {
                Field f = c.getDeclaredField(key);
                Object extra = extras.get(key);
                String value = extra.toString();
                f.set(this, extras.getString(value));
            } catch (SecurityException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();/*w w w . j  a v  a2  s.co  m*/
            } catch (NoSuchFieldException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    } else {

    }

    theaterViewIds = new HashMap();
    theaterViewValues = new HashMap();

    isUserDefault = false;

    resultsListView = (ListView) findViewById(R.id.resultsTable);
    resultsAdapter = new ResultsEfficientAdapter(this);

    businessNameArray = new ArrayList<String>();

    latitudeArray = new ArrayList<String>();

    longitudeArray = new ArrayList<String>();

    listingIdArray = new ArrayList<String>();

    phoneArray = new ArrayList<String>();

    callArray = new ArrayList<String>();

    streetArray = new ArrayList<String>();

    cityArray = new ArrayList<String>();
    resultsListView.setAdapter(resultsAdapter);
    didSelectViewController();

}

From source file:com.wareninja.opensource.common.wsrequest.WebServiceNew.java

public String webPost(String methodName, Bundle params) throws MalformedURLException, IOException {

    // random string as boundary for multi-part http post
    String strBoundary = "3i2ndDfv2rTHiSisAbouNdArYfORhtTPEefj3q2f";
    String endLine = "\r\n";
    OutputStream os;//w  w w .j av  a 2 s . com

    ret = null;

    String postUrl = webServiceUrl + methodName;

    if (LOGGING.DEBUG) {
        Log.d(TAG, "POST URL: " + postUrl);
    }
    HttpURLConnection conn = (HttpURLConnection) new URL(postUrl).openConnection();
    conn.setRequestProperty("User-Agent",
            System.getProperties().getProperty("http.agent") + " WareNinjaAndroidSDK");
    HttpParams httpParams = httpClient.getParams();
    HttpProtocolParams.setUseExpectContinue(httpParams, false);

    Bundle dataparams = new Bundle();
    for (String key : params.keySet()) {

        byte[] byteArr = null;
        try {
            byteArr = (byte[]) params.get(key);
        } catch (Exception ex1) {
        }
        if (byteArr != null)
            dataparams.putByteArray(key, byteArr);
    }

    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + strBoundary);
    conn.setDoOutput(true);
    conn.setDoInput(true);
    conn.setRequestProperty("Connection", "Keep-Alive");
    appendRequestHeaders(conn, headers);
    conn.connect();
    os = new BufferedOutputStream(conn.getOutputStream());

    os.write(("--" + strBoundary + endLine).getBytes());
    os.write((WareNinjaUtils.encodePostBody(params, strBoundary)).getBytes());
    os.write((endLine + "--" + strBoundary + endLine).getBytes());

    if (!dataparams.isEmpty()) {

        for (String key : dataparams.keySet()) {
            os.write(("Content-Disposition: form-data; filename=\"" + key + "\"" + endLine).getBytes());
            os.write(("Content-Type: content/unknown" + endLine + endLine).getBytes());
            os.write(dataparams.getByteArray(key));
            os.write((endLine + "--" + strBoundary + endLine).getBytes());

        }
    }
    os.flush();

    String response = "";
    try {
        response = WareNinjaUtils.read(conn.getInputStream());
    } catch (FileNotFoundException e) {
        // Error Stream contains JSON that we can parse to a FB error
        response = WareNinjaUtils.read(conn.getErrorStream());
    }
    if (LOGGING.DEBUG)
        Log.d(TAG, "POST response: " + response);

    return response;
}

From source file:com.money.manager.ex.notifications.SmsReceiverTransactions.java

@Override
public void onReceive(Context context, Intent intent) {
    mContext = context.getApplicationContext();

    final BehaviourSettings behav_settings = new BehaviourSettings(mContext);
    final GeneralSettings gen_settings = new GeneralSettings(mContext);
    final AppSettings app_settings = new AppSettings(mContext);
    final PreferenceConstants prf_const = new PreferenceConstants();

    //App Settings
    int baseCurencyID, fromCurrencyID, toCurrencyID;
    int baseAccountID, fromAccountID, toAccountID;

    String baseCurrencySymbl, fromAccCurrencySymbl, toAccCurrencySymbl;
    String baseAccountName, fromAccountName, toAccountName;

    Boolean autoTransactionStatus = false;
    Boolean skipSaveTrans = false;

    try {//from www.j  ava 2  s .  com
        //------- if settings enabled the parse the sms and create trans ---------------
        if (behav_settings.getBankSmsTrans() == true) {

            //---get the SMS message passed in---
            Bundle bundle = intent.getExtras();
            SmsMessage[] msgs = null;
            String msgBody = "";
            String msgSender = "";

            if (bundle != null) { //---retrieve the SMS message received---

                Object[] pdus = (Object[]) bundle.get("pdus");
                msgs = new SmsMessage[pdus.length];

                for (int i = 0; i < msgs.length; i++) {
                    msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
                    msgSender = msgs[i].getOriginatingAddress();
                    msgBody += msgs[i].getMessageBody().toString();
                }

                //msgSender = "AT-SIBSMS";

                if (isTransactionSms(msgSender)) {
                    // Transaction Sms sender will have format like this AT-SIBSMS,
                    // Promotional sms will have sender like AT-012345
                    // Not sure how this format will be in out side of India. May I need to update if i get sample

                    ITransactionEntity model = AccountTransaction.create();
                    mCommon = new EditTransactionCommonFunctions(null, model, database);

                    // find out the trans type using reg ex
                    String[] key_credit_search = { "(credited)", "(received)", "(added)", "(reloaded)",
                            "(deposited)", "(refunded)", "(debited)(.*?)(towards)(\\s)",
                            "(\\s)(received)(.*?)(in(\\s)your)(\\s)", "(sent)(.*?)(to)(\\s)",
                            "(debited)(.*?)(to)(\\s)", "(credited)(.*?)(in)(\\s)", "(credited)(.*?)(to)(\\s)" };

                    String[] key_debit_search = { "(made)", "(debited)", "(using)", "(paid)", "(purchase)",
                            "(withdrawn)", "(credited)(.*?)(from)(\\s)", "(sent)(.*?)(from)(\\s)",
                            "(\\s)(received)(.*?)(from)(\\s)" };

                    String transType = "";

                    Boolean isDeposit = validateTransType(key_credit_search, msgBody.toLowerCase());
                    Boolean isWithdrawal = validateTransType(key_debit_search, msgBody.toLowerCase());

                    if (isDeposit == true) {
                        if (isWithdrawal == true) {
                            transType = "Transfer";
                            String[] transCategory = getCategoryOrSubCategoryByName("Transfer");

                            if (!transCategory[0].isEmpty()) {
                                mCommon.transactionEntity.setCategoryId(parseInt(transCategory[0]));
                            }

                            if (!transCategory[1].isEmpty()) {
                                mCommon.transactionEntity.setSubcategoryId(parseInt(transCategory[1]));
                            }

                            mCommon.transactionEntity.setTransactionType(TransactionTypes.Transfer);

                        } else {
                            transType = "Deposit";
                            String[] incomeCategory = getCategoryOrSubCategoryByName("Income");

                            if (!incomeCategory[0].isEmpty()) {
                                mCommon.transactionEntity.setCategoryId(parseInt(incomeCategory[0]));
                            }

                            if (!incomeCategory[1].isEmpty()) {
                                mCommon.transactionEntity.setSubcategoryId(parseInt(incomeCategory[1]));
                            }

                            mCommon.transactionEntity.setTransactionType(TransactionTypes.Deposit);
                        }

                    } else if (isWithdrawal == true) {
                        transType = "Withdrawal";
                        mCommon.transactionEntity.setTransactionType(TransactionTypes.Withdrawal);
                    }

                    mCommon.transactionEntity.setStatus("");
                    mCommon.payeeName = "";

                    if (transType != "" && msgBody.toLowerCase().contains("otp") == false) { // if not from blank, then nothing to do with sms

                        //Create the intent thatll fire when the user taps the notification//
                        Intent t_intent = new Intent(mContext, CheckingTransactionEditActivity.class);

                        // Db setup
                        MmxHelper = new MmxOpenHelper(mContext,
                                app_settings.getDatabaseSettings().getDatabasePath());
                        db = MmxHelper.getReadableDatabase();

                        baseCurencyID = gen_settings.getBaseCurrencytId();
                        baseAccountID = gen_settings.getDefaultAccountId();
                        baseAccountName = "";
                        fromAccountID = -1;
                        fromCurrencyID = -1;
                        fromAccountName = "";

                        //if default account id selected
                        if (baseAccountID > 0) {
                            fromAccountID = baseAccountID;
                            fromAccountName = baseAccountName;
                            fromCurrencyID = baseCurencyID;
                        }

                        //Get the base currency sysmbl
                        baseCurrencySymbl = getCurrencySymbl(baseCurencyID);
                        fromAccCurrencySymbl = baseCurrencySymbl;

                        //get te from acount details
                        extractAccountDetails(msgBody, transType);

                        if (!fromAccountDetails[0].isEmpty()) {
                            fromAccountID = parseInt(fromAccountDetails[0]);
                            fromAccountName = fromAccountDetails[1];
                            fromCurrencyID = parseInt(fromAccountDetails[2]);
                            fromAccCurrencySymbl = fromAccountDetails[3];
                            mCommon.transactionEntity.setAccountId(fromAccountID);
                        }

                        mCommon.transactionEntity.setNotes(msgBody);
                        mCommon.transactionEntity.setDate(new MmxDate().toDate());

                        //get the trans amount
                        String transAmount = extractTransAmount(msgBody, fromAccCurrencySymbl);
                        String[] transPayee = extractTransPayee(msgBody);

                        //If there is no account no. or payee in the msg & no amt, then this is not valid sms to do transaction
                        if ((!fromAccountDetails[6].isEmpty() || !toAccountDetails[6].isEmpty()
                                || !transPayee[0].isEmpty()) && !transAmount.isEmpty()) {

                            mCommon.transactionEntity.setAmount(MoneyFactory.fromString(transAmount));

                            String transRefNo = extractTransRefNo(msgBody);

                            //set the ref no. if exists
                            if (!transRefNo.isEmpty()) {
                                mCommon.transactionEntity.setTransactionNumber(transRefNo);
                            }

                            int txnId = getTxnId(transRefNo.trim(), mCommon.transactionEntity.getDateString());

                            switch (txnId) {
                            case 0: //add new trnsaction

                                if (transType == "Transfer") //if it is transfer
                                {
                                    if (!toAccountDetails[0].isEmpty()) // if id exists then considering as account transfer
                                    {
                                        toAccountID = parseInt(toAccountDetails[0]);
                                        toAccountName = toAccountDetails[1];
                                        toCurrencyID = parseInt(toAccountDetails[2]);
                                        toAccCurrencySymbl = toAccountDetails[3];

                                        mCommon.transactionEntity.setAccountToId(toAccountID);

                                        //convert the to amount from the both currency details
                                        CurrencyService currencyService = new CurrencyService(mContext);
                                        mCommon.transactionEntity
                                                .setAmountTo(currencyService.doCurrencyExchange(fromCurrencyID,
                                                        mCommon.transactionEntity.getAmount(), toCurrencyID));

                                        mCommon.transactionEntity.setPayeeId(Constants.NOT_SET);

                                    } else { // if not, then IMPS transfer tp 3rd party

                                        transType = "Withdrawal";
                                        mCommon.transactionEntity
                                                .setTransactionType(TransactionTypes.Withdrawal);
                                        mCommon.transactionEntity.setAccountToId(Constants.NOT_SET);
                                        mCommon.transactionEntity
                                                .setAmountTo(MoneyFactory.fromString(transAmount));

                                        //if there is no to account found from mmex db, then check for payee
                                        //This will helps me to handle 3rd party transfer thru IMPS
                                        if (!toAccountDetails[6].isEmpty() && transPayee[0].isEmpty()) {
                                            transPayee = getPayeeDetails(toAccountDetails[6].trim());
                                        }
                                    }
                                } else {
                                    mCommon.transactionEntity.setAccountToId(Constants.NOT_SET);
                                    mCommon.transactionEntity.setAmountTo(MoneyFactory.fromString(transAmount));
                                }

                                if (!transPayee[0].isEmpty()) {

                                    mCommon.transactionEntity.setPayeeId(parseInt(transPayee[0]));
                                    mCommon.payeeName = transPayee[1];
                                    mCommon.transactionEntity.setCategoryId(parseInt(transPayee[2]));
                                    mCommon.transactionEntity.setSubcategoryId(parseInt(transPayee[3]));
                                }

                                t_intent.setAction(Intent.ACTION_INSERT); //Set the action

                                break;

                            default: //Update existing transaction

                                transType = "Transfer";

                                AccountTransactionRepository repo = new AccountTransactionRepository(mContext);
                                AccountTransaction txn = repo.load(txnId);

                                if (txn != null) {

                                    if (txn.getTransactionType() != TransactionTypes.Transfer) {

                                        AccountRepository accountRepository = new AccountRepository(mContext);

                                        if (txn.getTransactionType() == TransactionTypes.Deposit) {
                                            toAccountID = txn.getAccountId();
                                            toCurrencyID = accountRepository
                                                    .loadCurrencyIdFor(txn.getAccountId());
                                        } else {
                                            toAccountID = fromAccountID;
                                            toCurrencyID = fromCurrencyID;
                                            fromCurrencyID = accountRepository
                                                    .loadCurrencyIdFor(txn.getAccountId());
                                        }

                                        mCommon.transactionEntity = txn;
                                        mCommon.transactionEntity.setTransactionType(TransactionTypes.Transfer);
                                        mCommon.transactionEntity.setAccountId(fromAccountID);
                                        mCommon.transactionEntity.setAccountToId(toAccountID);

                                        //convert the to amount from the both currency details
                                        CurrencyService currencyService = new CurrencyService(mContext);
                                        mCommon.transactionEntity
                                                .setAmountTo(currencyService.doCurrencyExchange(fromCurrencyID,
                                                        mCommon.transactionEntity.getAmount(), toCurrencyID));

                                        mCommon.transactionEntity.setPayeeId(Constants.NOT_SET);

                                        String[] transCategory = getCategoryOrSubCategoryByName("Transfer");
                                        if (!transCategory[0].isEmpty()) {
                                            mCommon.transactionEntity.setCategoryId(parseInt(transCategory[0]));
                                            mCommon.transactionEntity
                                                    .setSubcategoryId(parseInt(transCategory[1]));
                                        }

                                        mCommon.transactionEntity.setNotes(
                                                mCommon.transactionEntity.getNotes() + "\n\n" + msgBody);

                                        t_intent.setAction(Intent.ACTION_EDIT); //Set the action
                                    } else //if transfer already exists, then do nothing
                                    {
                                        skipSaveTrans = true;
                                    }

                                }

                            }

                            // Capture the details the for Toast
                            String strExtracted = "Account = " + fromAccountName + "-" + fromAccountDetails[6]
                                    + "\n" + "Trans Amt = " + fromAccCurrencySymbl + " " + transAmount + ",\n"
                                    + "Payyee Name= " + transPayee[1] + "\n" + "Category ID = " + transPayee[2]
                                    + "\n" + "Sub Category ID = " + transPayee[3] + "\n" + "Trans Ref No. = "
                                    + transRefNo + "\n" + "Trans Type = " + transType + "\n";

                            //Must be commented for released version
                            //mCommon.transactionEntity.setNotes(strExtracted);

                            // Set the content for a transaction);
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_SOURCE,
                                    "SmsReceiverTransactions.java");
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_ID,
                                    mCommon.transactionEntity.getId());
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_ACCOUNT_ID,
                                    String.valueOf(mCommon.transactionEntity.getAccountId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TO_ACCOUNT_ID,
                                    String.valueOf(mCommon.transactionEntity.getAccountToId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_CODE,
                                    mCommon.getTransactionType());
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_PAYEE_ID,
                                    String.valueOf(mCommon.transactionEntity.getPayeeId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_PAYEE_NAME,
                                    mCommon.payeeName);
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_CATEGORY_ID,
                                    String.valueOf(mCommon.transactionEntity.getCategoryId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_SUBCATEGORY_ID,
                                    String.valueOf(mCommon.transactionEntity.getSubcategoryId()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_AMOUNT,
                                    String.valueOf(mCommon.transactionEntity.getAmount()));
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_NOTES,
                                    mCommon.transactionEntity.getNotes());
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_DATE,
                                    new MmxDate().toDate());
                            t_intent.putExtra(EditTransactionActivityConstants.KEY_TRANS_NUMBER,
                                    mCommon.transactionEntity.getTransactionNumber());

                            // validate and save the transaction
                            if (skipSaveTrans == false) {
                                if (validateData()) {
                                    if (saveTransaction()) {
                                        Toast.makeText(context,
                                                "MMEX: Bank Transaction Processed for: \n\n" + strExtracted,
                                                Toast.LENGTH_LONG).show();
                                        autoTransactionStatus = true;
                                    }
                                }

                                //if transaction is not created automatically, then invoke notification or activity screen
                                if (autoTransactionStatus == false) {
                                    startActivity(mContext, t_intent, null);
                                    //showNotification(t_intent, strExtracted);
                                }
                            } else {
                                Toast.makeText(context,
                                        "MMEX: Skiping Bank Transaction updates SMS, because transaction exists with ref. no. "
                                                + transRefNo,
                                        Toast.LENGTH_LONG).show();
                            }

                            //reset the value
                            msgBody = "";
                            msgSender = "";
                            bundle = null;
                            msgs = null;
                            mCommon = null;
                            skipSaveTrans = false;

                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        Timber.e(e, "MMEX: Bank Transaction Process EXCEPTION");
    }
}

From source file:com.rothconsulting.android.billing.util.IabHelper.java

int queryPurchases(Inventory inv, String itemType) throws JSONException, RemoteException {
    // Query purchases
    logDebug("Querying owned items, item type: " + itemType);
    logDebug("Package name: " + mContext.getPackageName());
    boolean verificationFailed = false;
    String continueToken = null;// w ww  .j a  va 2  s  .co m

    do {
        logDebug("Calling getPurchases with continuation token: " + continueToken);
        Bundle ownedItems = mService.getPurchases(3, mContext.getPackageName(), itemType, continueToken);

        Utils.log(mDebugTag, "++ --- ownedItems from Service = " + ownedItems);
        Utils.log(mDebugTag, "++ --- ownedItems itemType = " + itemType);
        Utils.log(mDebugTag, "++ --- ownedItems keySet  = " + ownedItems.keySet());
        Utils.log(mDebugTag, "++ --- ownedItems isEmpty = " + ownedItems.isEmpty());
        Utils.log(mDebugTag,
                "++ --- ownedItems INAPP_PURCHASE_ITEM_LIST = " + ownedItems.get("INAPP_PURCHASE_ITEM_LIST"));
        Utils.log(mDebugTag,
                "++ --- ownedItems INAPP_PURCHASE_DATA_LIST = " + ownedItems.get("INAPP_PURCHASE_DATA_LIST"));
        Utils.log(mDebugTag,
                "++ --- ownedItems INAPP_DATA_SIGNATURE_LIST = " + ownedItems.get("INAPP_DATA_SIGNATURE_LIST"));
        Utils.log(mDebugTag, "++ --- ownedItems RESPONSE_CODE = " + ownedItems.get("RESPONSE_CODE"));

        int response = getResponseCodeFromBundle(ownedItems);
        logDebug("Owned items response: " + String.valueOf(response));
        if (response != BILLING_RESPONSE_RESULT_OK) {
            logDebug("getPurchases() failed: " + getResponseDesc(response));
            return response;
        }
        if (!ownedItems.containsKey(RESPONSE_INAPP_ITEM_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_PURCHASE_DATA_LIST)
                || !ownedItems.containsKey(RESPONSE_INAPP_SIGNATURE_LIST)) {
            logError("Bundle returned from getPurchases() doesn't contain required fields.");
            return IABHELPER_BAD_RESPONSE;
        }

        ArrayList<String> ownedSkus = ownedItems.getStringArrayList(RESPONSE_INAPP_ITEM_LIST);
        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);
            String sku = ownedSkus.get(i);
            if (Security.verifyPurchase(mSignatureBase64, purchaseData, signature)) {
                logDebug("Sku is owned: " + sku);
                Purchase purchase = new Purchase(itemType, purchaseData, signature);

                if (TextUtils.isEmpty(purchase.getToken())) {
                    logWarn("BUG: empty/null token!");
                    logDebug("Purchase data: " + purchaseData);
                }

                // Record ownership and token
                inv.addPurchase(purchase);
            } else {
                logWarn("Purchase signature verification **FAILED**. Not adding item.");
                logDebug("   Purchase data: " + purchaseData);
                logDebug("   Signature: " + signature);
                verificationFailed = true;
            }
        }

        continueToken = ownedItems.getString(INAPP_CONTINUATION_TOKEN);
        logDebug("Continuation token: " + continueToken);
    } while (!TextUtils.isEmpty(continueToken));

    return verificationFailed ? IABHELPER_VERIFICATION_FAILED : BILLING_RESPONSE_RESULT_OK;
}

From source file:com.android.providers.contacts.ContactsSyncAdapter.java

@Override
public void getServerDiffs(SyncContext context, SyncData baseSyncData, SyncableContentProvider tempProvider,
        Bundle extras, Object syncInfo, SyncResult syncResult) {
    mPerformedGetServerDiffs = true;//from ww w  . ja v  a 2  s. c  o m
    GDataSyncData syncData = (GDataSyncData) baseSyncData;

    ArrayList<String> feedsToSync = new ArrayList<String>();

    if (extras != null && extras.containsKey("feed")) {
        feedsToSync.add((String) extras.get("feed"));
    } else {
        feedsToSync.add(getGroupsFeedForAccount(getAccount()));
        addContactsFeedsToSync(getContext().getContentResolver(), getAccount(), feedsToSync);
        feedsToSync.add(getPhotosFeedForAccount(getAccount()));
    }

    for (String feed : feedsToSync) {
        context.setStatusText("Downloading\u2026");
        if (getPhotosFeedForAccount(getAccount()).equals(feed)) {
            getServerPhotos(context, feed, MAX_MEDIA_ENTRIES_PER_SYNC, syncData, syncResult);
        } else {
            final Class feedEntryClass = getFeedEntryClass(feed);
            if (feedEntryClass != null) {
                getServerDiffsImpl(context, tempProvider, feedEntryClass, feed, null, getMaxEntriesPerSync(),
                        syncData, syncResult);
            } else {
                if (Config.LOGD) {
                    Log.d(TAG, "ignoring sync request for unknown feed " + feed);
                }
            }
        }
        if (syncResult.hasError()) {
            break;
        }
    }
}

From source file:com.android.talkback.SpeechController.java

private boolean processNextFragmentInternal() {
    if (mCurrentFragmentIterator == null || !mCurrentFragmentIterator.hasNext()) {
        return false;
    }/* www. ja  va2s. c o  m*/

    FeedbackFragment fragment = mCurrentFragmentIterator.next();
    playEarconsFromFragment(fragment);
    playHapticsFromFragment(fragment);

    // Reuse the global instance of speech parameters.
    final HashMap<String, String> params = mSpeechParametersMap;
    params.clear();

    // Add all custom speech parameters.
    final Bundle speechParams = fragment.getSpeechParams();
    for (String key : speechParams.keySet()) {
        params.put(key, String.valueOf(speechParams.get(key)));
    }

    // Utterance ID, stream, and volume override item params.
    params.put(Engine.KEY_PARAM_UTTERANCE_ID, mCurrentFeedbackItem.getUtteranceId());
    params.put(Engine.KEY_PARAM_STREAM, String.valueOf(DEFAULT_STREAM));
    params.put(Engine.KEY_PARAM_VOLUME, String.valueOf(mSpeechVolume));

    final float pitch = mSpeechPitch * (mUseIntonation ? parseFloatParam(params, SpeechParam.PITCH, 1) : 1);
    final float rate = mSpeechRate * (mUseIntonation ? parseFloatParam(params, SpeechParam.RATE, 1) : 1);
    final CharSequence text;
    if (shouldSilenceSpeech(mCurrentFeedbackItem) || TextUtils.isEmpty(fragment.getText())) {
        text = null;
    } else {
        text = fragment.getText();
    }

    String logText = text == null ? null : text.toString();
    LogUtils.log(this, Log.VERBOSE, "Speaking fragment text \"%s\"", logText);

    mVoiceRecognitionChecker.onUtteranceStart();

    // It's okay if the utterance is empty, the fail-over TTS will
    // immediately call the fragment completion listener. This process is
    // important for things like continuous reading.
    mFailoverTts.speak(text, pitch, rate, params, DEFAULT_STREAM, mSpeechVolume);

    if (mTtsOverlay != null) {
        mTtsOverlay.speak(text);
    }

    return true;
}

From source file:com.facebook.Request.java

private static void serializeParameters(Bundle bundle, Serializer serializer, Request request)
        throws IOException {
    Set<String> keys = bundle.keySet();

    for (String key : keys) {
        Object value = bundle.get(key);
        if (isSupportedParameterType(value)) {
            serializer.writeObject(key, value, request);
        }/*from w  w w  . java2  s. c o m*/
    }
}

From source file:br.org.funcate.dynamicforms.FragmentDetail.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.details, container, false);
    LinearLayout mainView = (LinearLayout) view.findViewById(R.id.form_linear);
    FragmentDetailActivity fragmentDetailActivity;
    try {/*from   w  w  w.ja  va2s  . com*/
        FragmentActivity activity = getActivity();
        if (selectedFormName == null || sectionObject == null) {
            FragmentList fragmentList = (FragmentList) getFragmentManager().findFragmentById(R.id.listFragment);
            if (fragmentList != null) {
                selectedFormName = fragmentList.getSelectedItemName();
                sectionObject = fragmentList.getSectionObject();
                noteId = fragmentList.getNoteId();
            } else {
                if (activity instanceof FragmentDetailActivity) {
                    // case of portrait mode
                    fragmentDetailActivity = (FragmentDetailActivity) activity;
                    selectedFormName = fragmentDetailActivity.getFormName();
                    sectionObject = fragmentDetailActivity.getSectionObject();
                    noteId = fragmentDetailActivity.getNoteId();
                    workingDirectory = fragmentDetailActivity.getWorkingDirectory();
                    existingFeatureData = fragmentDetailActivity.getFeatureData();
                }
            }
        }
        if (selectedFormName != null) {
            JSONObject formObject = TagsManager.getForm4Name(selectedFormName, sectionObject);

            key2WidgetMap.clear();
            requestCodes2WidgetMap.clear();
            int requestCode = 666;
            keyList.clear();
            key2ConstraintsMap.clear();

            if (formObject != null) {// Test to get form configuration to this layer

                JSONArray formItemsArray = TagsManager.getFormItems(formObject);

                int length = ((formItemsArray != null) ? (formItemsArray.length()) : (0));
                for (int i = 0; i < length; i++) {
                    JSONObject jsonObject = formItemsArray.getJSONObject(i);

                    String key = "-"; //$NON-NLS-1$
                    if (jsonObject.has(TAG_KEY))
                        key = jsonObject.getString(TAG_KEY).trim();

                    String label = key;
                    if (jsonObject.has(TAG_LABEL))
                        label = jsonObject.getString(TAG_LABEL).trim();

                    String type = FormUtilities.TYPE_STRING;
                    if (jsonObject.has(TAG_TYPE)) {
                        type = jsonObject.getString(TAG_TYPE).trim();
                    }

                    boolean readonly = false;
                    if (jsonObject.has(TAG_READONLY)) {
                        String readonlyStr = jsonObject.getString(TAG_READONLY).trim();
                        readonly = Boolean.parseBoolean(readonlyStr);
                    }
                    // if attribute has a non printable char, force readonly mode.
                    if (Utilities.existUnprintableCharacters(key)) {
                        readonly = true;
                    }

                    Constraints constraints = new Constraints();
                    FormUtilities.handleConstraints(jsonObject, constraints);
                    key2ConstraintsMap.put(key, constraints);
                    String constraintDescription = constraints.getDescription();

                    Object o;
                    GView addedView = null;
                    if (type.equals(TYPE_STRING)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addEditText(activity, mainView, label, value, 0, 0,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_STRINGAREA)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addEditText(activity, mainView, label, value, 0, 7,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_DOUBLE)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addEditText(activity, mainView, label, value, 1, 0,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_INTEGER)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addEditText(activity, mainView, label, value, 4, 0,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_DATE)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addDateView(FragmentDetail.this, mainView, label, value,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_TIME)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addTimeView(FragmentDetail.this, mainView, label, value,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_LABEL)) {
                        String size = "20"; //$NON-NLS-1$
                        if (jsonObject.has(TAG_SIZE))
                            size = jsonObject.getString(TAG_SIZE);
                        String url = null;
                        if (jsonObject.has(TAG_URL))
                            url = jsonObject.getString(TAG_URL);

                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addTextView(activity, mainView, value, size, false, url);
                    } else if (type.equals(TYPE_LABELWITHLINE)) {
                        String size = "20"; //$NON-NLS-1$
                        if (jsonObject.has(TAG_SIZE))
                            size = jsonObject.getString(TAG_SIZE);
                        String url = null;
                        if (jsonObject.has(TAG_URL))
                            url = jsonObject.getString(TAG_URL);

                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addTextView(activity, mainView, value, size, true, url);
                    } else if (type.equals(TYPE_BOOLEAN)) {
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addBooleanView(activity, mainView, label, value,
                                constraintDescription, readonly);
                    } else if (type.equals(TYPE_STRINGCOMBO)) {
                        JSONArray comboItems = TagsManager.getComboItems(jsonObject);
                        String[] itemsArray = TagsManager.comboItems2StringArray(comboItems);
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addComboView(activity, mainView, label, value, itemsArray,
                                constraintDescription);
                    } else if (type.equals(TYPE_CONNECTEDSTRINGCOMBO)) {
                        LinkedHashMap<String, List<String>> valuesMap = TagsManager
                                .extractComboValuesMap(jsonObject);
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addConnectedComboView(activity, mainView, label, value,
                                valuesMap, constraintDescription);
                    } else if (type.equals(TYPE_STRINGMULTIPLECHOICE)) {
                        JSONArray comboItems = TagsManager.getComboItems(jsonObject);
                        String[] itemsArray = TagsManager.comboItems2StringArray(comboItems);
                        o = getValueFromExtras(jsonObject, key);
                        String value = ((String) o).trim();
                        addedView = FormUtilities.addMultiSelectionView(activity, mainView, label, value,
                                itemsArray, constraintDescription);
                    } else if (type.equals(TYPE_PICTURES)) {

                        o = getValueFromExtras(jsonObject, FormUtilities.IMAGE_MAP);
                        Map<String, Map<String, String>> value = null;
                        String clazz = o.getClass().getSimpleName();
                        if (("bundle").equalsIgnoreCase(clazz)) {
                            Bundle imageMapBundle = (Bundle) o;

                            Bundle imageMapThumbnailBundle = imageMapBundle.getBundle("thumbnail");
                            Bundle imageMapDisplayBundle = imageMapBundle.getBundle("display");

                            if (imageMapThumbnailBundle != null && imageMapDisplayBundle != null) {
                                Set<String> keys = imageMapThumbnailBundle.keySet();
                                Iterator<String> itKeys = keys.iterator();

                                if (keys.size() > 0) {
                                    value = new HashMap<String, Map<String, String>>(keys.size());

                                    while (itKeys.hasNext()) {
                                        String keyMap = itKeys.next();
                                        Map<String, String> imagePaths = new HashMap<String, String>(2);
                                        imagePaths.put("thumbnail",
                                                (String) imageMapThumbnailBundle.get(keyMap));
                                        imagePaths.put("display", (String) imageMapDisplayBundle.get(keyMap));

                                        value.put(keyMap, imagePaths);
                                    }
                                }
                            }
                        }
                        addedView = FormUtilities.addPictureView(this, requestCode, mainView, label, value,
                                constraintDescription);
                    }
                    /*else if (type.equals(TYPE_SKETCH)) {
                    addedView = FormUtilities.addSketchView(noteId, this, requestCode, mainView, label, value, constraintDescription);
                    } */
                    else {
                        Toast.makeText(getActivity().getApplicationContext(),
                                "Type non implemented yet: " + type, Toast.LENGTH_LONG).show();
                    }
                    /*                    } else if (type.equals(TYPE_MAP)) {
                    if (value.length() <= 0) {
                        // need to read image
                        File tempDir = ResourcesManager.getInstance(activity).getTempDir();
                        File tmpImage = new File(tempDir, LibraryConstants.TMPPNGIMAGENAME);
                        if (tmpImage.exists()) {
                            byte[][] imageAndThumbnailFromPath = ImageUtilities.getImageAndThumbnailFromPath(tmpImage.getAbsolutePath(), 1);
                            Date date = new Date();
                            String mapImageName = ImageUtilities.getMapImageName(date);
                            
                            IImagesDbHelper imageHelper = DefaultHelperClasses.getDefaulfImageHelper();
                            long imageId = imageHelper.addImage(longitude, latitude, -1.0, -1.0, date.getTime(), mapImageName, imageAndThumbnailFromPath[0], imageAndThumbnailFromPath[1], noteId);
                            value = "" + imageId;
                        }
                    }
                    addedView = FormUtilities.addMapView(activity, mainView, label, value, constraintDescription);
                                        } else if (type.equals(TYPE_NFCUID)) {
                    addedView = new GNfcUidView(this, null, requestCode, mainView, label, value, constraintDescription);
                                        } else {
                    GPLog.addLogEntry(this, null, null, "Type non implemented yet: " + type);
                                        }*/
                    key2WidgetMap.put(key, addedView);
                    keyList.add(key);
                    requestCodes2WidgetMap.put(requestCode, addedView);
                    requestCode++;
                } // end of the form items loop
            } else {
                String size = "20"; //$NON-NLS-1$
                String url = null;
                String value = getResources().getString(R.string.error_while_loading_form_configuration);
                GView addedView = FormUtilities.addTextView(activity, mainView, value, size, true, url);
                String key = "-"; //$NON-NLS-1$
                key2WidgetMap.put(key, addedView);
                keyList.add(key);
                requestCodes2WidgetMap.put(requestCode, addedView);
            }

            LinearLayout btnLinear = (LinearLayout) mainView.findViewById(R.id.btn_linear);
            if (keyList.size() == 1) {
                Button btnSave = (Button) btnLinear.findViewById(R.id.saveButton);
                btnSave.setEnabled(false);
            }
            mainView.removeView(btnLinear);
            mainView.addView(btnLinear);
        }
    } catch (ParseException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(getActivity().getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show();
    }

    return view;
}

From source file:com.google.android.apps.paco.ExperimentExecutorCustomRendering.java

private void renderWebView(Bundle savedInstanceState) {
    webView = (WebView) findViewById(R.id.experimentExecutorView);
    webView.getSettings().setJavaScriptEnabled(true);

    injectObjectsIntoJavascriptEnvironment();
    setWebChromeClientThatHandlesAlertsAsDialogs();
    WebViewClient webViewClient = createWebViewClientThatHandlesFileLinksForCharts();
    webView.setWebViewClient(webViewClient);
    loadCustomRendererIntoWebView();/*from ww  w.j  a v  a  2s.co m*/
    if (savedInstanceState != null) {
        webView.loadUrl((String) savedInstanceState.get("url"));
        String showDialogString = (String) savedInstanceState.get("showDialog");
        if (showDialogString == null || showDialogString.equals("false")) {
            showDialog = false;
        } else {
            showDialog = true;
        }
    }
}