Example usage for android.os Bundle containsKey

List of usage examples for android.os Bundle containsKey

Introduction

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

Prototype

public boolean containsKey(String key) 

Source Link

Document

Returns true if the given key is contained in the mapping of this Bundle.

Usage

From source file:com.appsimobile.appsii.iab.IabInventoryHelper.java

private 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;// ww w. j av  a2s .  c  om

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

        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.hybris.mobile.app.commerce.fragment.CatalogMenuFragment.java

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

    // Restore the current category
    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey(SAVED_INSTANCE_CATEGORY)) {
            mCurrentCategoryId = savedInstanceState.getString(SAVED_INSTANCE_CATEGORY);
        }/*from   ww w.  ja  v  a 2 s . c  o  m*/

        if (savedInstanceState.containsKey(SAVED_INSTANCE_OPEN_BY_DEFAULT)) {
            mOpenByDefault = savedInstanceState.getBoolean(SAVED_INSTANCE_OPEN_BY_DEFAULT);
        }
    }

    mCatalogMenuViewFlipper = (ViewFlipper) getActivity().findViewById(R.id.catalog_menu_fragment);

    // The catalog menu does not add any overlay on the screen
    mCatalogMenuDrawerLayout = ((DrawerLayout) getActivity().findViewById(R.id.catalog_menu_drawer));
    mCatalogMenuDrawerLayout.setScrimColor(Color.TRANSPARENT);

    // Call the API to get the catalog list
    QueryCatalog queryCatalog = new QueryCatalog();
    queryCatalog.setCatalogId(CommerceApplication.getContentServiceHelper().getConfiguration().getCatalogId());
    queryCatalog.setCatalogVersionId(
            CommerceApplication.getContentServiceHelper().getConfiguration().getCatalogVersionId());
    queryCatalog.setCatalogCategoryId(
            CommerceApplication.getContentServiceHelper().getConfiguration().getCatalogIdMainCategory());

    CommerceApplication.getContentServiceHelper().getCatalogCategory(this, mCatalogRequestId, queryCatalog,
            true, null, new OnRequestListener() {

                @Override
                public void beforeRequest() {
                    UIUtils.showLoadingActionBar(getActivity(), true);
                }

                @Override
                public void afterRequestBeforeResponse() {

                }

                @Override
                public void afterRequest(boolean isDataSynced) {
                    UIUtils.showLoadingActionBar(getActivity(), false);
                }
            });

}

From source file:com.karura.framework.PluginManager.java

/**
 * Called when the webview attached with the plugin manager is being restored with instance data
 * /*from   w  ww.j  a  va 2  s  . c  o m*/
 * Lets try to recreate all plugins with instance data
 * 
 * @param savedInstance
 *            the memory block which contains information about each of the plugins which were persisted in call to onSaveInstanceState
 */
public void onRestoreInstanceState(Bundle savedInstance) {
    // See if there is a valid instance to restore state from
    if (savedInstance == null || !savedInstance.containsKey(PLUGIN_MGR_INSTANCE_DATA_KEY))
        return;

    Bundle pluginMgrInstanceData = savedInstance.getBundle(PLUGIN_MGR_INSTANCE_DATA_KEY);
    _nextPluginId = 0;
    for (String pluginDataKey : pluginMgrInstanceData.keySet()) {

        // only process those data keys which were created by us
        if (!pluginDataKey.startsWith(PLUGIN_INSTANCE_DATA_KEY_PREFIX)) {
            continue;
        }

        // try and retrieve plugin specific instance data
        Bundle pluginInstanceData = pluginMgrInstanceData.getBundle(pluginDataKey);

        if (pluginInstanceData == null)
            continue;

        String clazz = pluginInstanceData.getString(PLUGIN_CLASS_NAME_KEY);
        pluginInstanceData.remove(PLUGIN_CLASS_NAME_KEY);
        Integer pluginId = Integer.valueOf(pluginInstanceData.getString(PLUGIN_ID_KEY));

        // manage the plugin id counter for subsequent allocation of plugins
        if (_nextPluginId < pluginId) {
            _nextPluginId = pluginId;
        }
        pluginInstanceData.remove(PLUGIN_ID_KEY);

        // Since we are passing the instance data for the plugin in this call, we are hoping it
        // will be able to restore its state
        allocateAndCachePlugin(clazz, pluginId, pluginInstanceData);

    }
    // safe increment
    _nextPluginId++;

    // TODO create a list of pluginIds and pass them back to the javascript layer just in case

}

From source file:com.ryan.ryanreader.fragments.PostListingFragment.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    // TODO load position/etc?
    super.onCreate(savedInstanceState);

    final Bundle arguments = getArguments();

    subreddit = arguments.getParcelable("subreddit");

    url = General.uriFromString(arguments.getString("url"));

    if (arguments.containsKey("session")) {
        session = UUID.fromString(arguments.getString("session"));
    }//from  ww  w . ja  v a 2  s  . c o m

    downloadType = CacheRequest.DownloadType.valueOf(arguments.getString("downloadType"));
}

From source file:com.arellomobile.android.push.PushManager.java

boolean onHandlePush(Activity activity) {
    Bundle pushBundle = activity.getIntent().getBundleExtra("pushBundle");
    if (null == pushBundle || null == mContext) {
        return false;
    }//from w  w  w.  j  a v  a  2s .  c  o m

    mLastBundle = pushBundle;

    JSONObject dataObject = new JSONObject();
    try {
        if (pushBundle.containsKey("title")) {
            dataObject.put("title", pushBundle.get("title"));
        }
        if (pushBundle.containsKey("u")) {
            dataObject.put("userdata", pushBundle.get("u"));
        }
        if (pushBundle.containsKey("local")) {
            dataObject.put("local", pushBundle.get("local"));
        }
    } catch (JSONException e) {
        // pass
    }

    PushEventsTransmitter.onMessageReceive(mContext, dataObject.toString(), pushBundle);

    // push message handling
    String url = (String) pushBundle.get("h");

    if (url != null) {
        url = String.format(HTML_URL_FORMAT, url);

        // show browser
        Intent intent = new Intent(activity, PushWebview.class);
        intent.putExtra("url", url);
        activity.startActivity(intent);
    }

    // send pushwoosh callback
    sendPushStat(mContext, pushBundle.getString("p"));

    return true;
}

From source file:eu.faircode.netguard.IAB.java

public PendingIntent getBuyIntent(String sku, boolean subscription) throws RemoteException {
    if (service == null)
        return null;
    Bundle bundle = service.getBuyIntent(IAB_VERSION, context.getPackageName(), sku,
            subscription ? "subs" : "inapp", "netguard");
    Log.i(TAG, "getBuyIntent sku=" + sku + " subscription=" + subscription);
    Util.logBundle(bundle);//from  w w w .  java  2  s . c  o  m
    int response = (bundle == null ? -1 : bundle.getInt("RESPONSE_CODE", -1));
    Log.i(TAG, "Response=" + getResult(response));
    if (response != 0)
        throw new IllegalArgumentException(getResult(response));
    if (!bundle.containsKey("BUY_INTENT"))
        throw new IllegalArgumentException("BUY_INTENT missing");
    return bundle.getParcelable("BUY_INTENT");
}

From source file:com.wglxy.example.dashL.SearchActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search);
    setTitleFromActivityLabel(R.id.title_text);
    showLogginLogout(findViewById(R.id.btn_login_logout));

    initUI();// w  ww . j av a  2 s .co m
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SEARCH_QUERY)
            && savedInstanceState.containsKey(KEY_USER_OBJ)) {
        searchStr = savedInstanceState.getString(KEY_SEARCH_QUERY);
        data = savedInstanceState.getParcelableArrayList(KEY_USER_OBJ);
    }

    try {
        Bundle args = getIntent().getExtras();
        searchStr = args.getString(Constants.KEY_SEARCH_ARGS);
        Log.e(LOG_TAG, "search query: " + searchStr);
        doSearch(searchStr);
    } catch (Exception ex) {
        Log.e(LOG_TAG, "no search args", ex.getCause());
        searchBar.setVisibility(View.VISIBLE);
        edt_search.requestFocus();
    }
}

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

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

    // don't permit rotation
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {//from   w  ww .j  a va  2 s .  c o m
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    String tags = "";
    String defaultSectionName = FormUtilities.DEFAULT_SESSION_NAME;

    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    String geojsonTags = "";
    if (extras != null) {
        pointId = extras.getLong(LibraryConstants.SELECTED_POINT_ID);
        formName = extras.getString(FormUtilities.ATTR_FORMNAME);
        tags = extras.getString(FormUtilities.ATTR_JSON_TAGS);

        if (extras.containsKey(FormUtilities.ATTR_GEOJSON_TAGS)) {
            geojsonTags = extras.getString(FormUtilities.ATTR_GEOJSON_TAGS);
        }
        // here are the attribute values from feature to populate form in edit operation
        if (extras.containsKey(FormUtilities.ATTR_DATA_VALUES)) {
            existingFeatureData = extras.getBundle(FormUtilities.ATTR_DATA_VALUES);
        }
        workingDirectory = extras.getString(FormUtilities.MAIN_APP_WORKING_DIRECTORY);
    }

    try {
        sectionObject = TagsManager.getInstance(tags).getSectionByName(defaultSectionName);

        if (sectionObject == null) {
            Toast.makeText(getApplicationContext(), "Failure on get form session.", Toast.LENGTH_LONG).show();
            System.out.println("Failure on load JSON form from database.");
            this.finish();
        }

        JSONObject geojson = new JSONObject(geojsonTags);
        sectionObject.put(FormUtilities.ATTR_GEOJSON_TAGS, geojson);

    } catch (JSONException e) {
        Toast.makeText(getApplicationContext(), "Incorrect form configuration.", Toast.LENGTH_LONG).show();
        System.out.println("Failure on load JSON form from database.");
        e.printStackTrace();
        this.finish();
    }

    setContentView(R.layout.details_activity_layout);
}

From source file:org.rapidandroid.activity.FormReviewer.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setTitle(getString(R.string.app_name) + " :: Review Form");
    setContentView(R.layout.form_edit);// ww w  . j  av  a  2 s  . c  o m

    Bundle extras = getIntent().getExtras();
    if (extras != null) {

        if (!extras.containsKey(CallParams.REVIEW_FORM)) {
            throw new IllegalArgumentException("Error, activity was called without a Form ID to review.");
        }
        int formID = extras.getInt(CallParams.REVIEW_FORM);
        mForm = ModelTranslator.getFormById(formID);

        TextView txv_formname = (TextView) findViewById(R.id.txv_formname);
        TextView txv_prefix = (TextView) findViewById(R.id.txv_formprefix);
        TextView txv_description = (TextView) findViewById(R.id.txv_description);
        TextView txv_parsertype = (TextView) findViewById(R.id.txv_parsertype);
        ListView lsv_fields = (ListView) findViewById(R.id.lsv_fields);

        txv_formname.setText(mForm.getFormName());
        txv_prefix.setText(mForm.getPrefix());
        txv_description.setText(mForm.getDescription());
        txv_parsertype.setText(mForm.getParserType().toString());
        //         int len = mForm.getFields().length;

        // lsv_fields.setAdapter(new ArrayAdapter<String>(this,
        // android.R.layout.simple_list_item_1, fields));
        ArrayList<Field> fields = new ArrayList<Field>();
        Field[] f = mForm.getFields();
        for (Field ff : f) {
            fields.add(ff);
        }
        lsv_fields.setAdapter(new FieldViewAdapter(this, fields));

    }
}